我正在尝试使用Lifray 7.1上的yo主题生成器生成主题。我遵循了下面链接上的步骤,我的问题是在运行这个命令";npm安装-g-yo";它无法正确安装yo。我不知道为什么?!但这就是我得到的:
C:Windowssystem32>npm install --global yo
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
C:UsershdalaAppDataRoamingnpmyo -> C:UsershdalaAppDataRoamingnpmnode_modulesyolibcli.js
C:UsershdalaAppDataRoamingnpmyo-complete -> C:UsershdalaAppDataRoamingnpmnode_modulesyolibcompletionindex.js
> yo@4.2.0 postinstall C:UsershdalaAppDataRoamingnpmnode_modulesyo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
√ No .bowerrc file in home directory
√ Global configuration file is valid
√ NODE_PATH matches the npm root
√ No .yo-rc.json file in home directory
√ Node.js version
√ npm version
{ Error: Command failed: C:Windowssystem32cmd.exe /s /c "yo "--version""
C:UsershdalaAppDataRoamingnpmnode_modulesyonode_modulesyeoman-environmentlibenvironment.js:534
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:UsershdalaAppDataRoamingnpmnode_modulesyolibrouter.js:8:27)
at ChildProcess.exithandler (child_process.js:275:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at ChildProcess.cp.emit (C:UsershdalaAppDataRoamingnpmnode_modulesyonode_modulescross-spawn-asynclibenoent.js:37:29)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
killed: false,
code: 1,
signal: null,
cmd: 'C:\Windows\system32\cmd.exe /s /c "yo "--version""' }
× yo version
{ Error: Command failed: C:Windowssystem32cmd.exe /s /c "yo "--version""
C:UsershdalaAppDataRoamingnpmnode_modulesyonode_modulesyeoman-environmentlibenvironment.js:534
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:UsershdalaAppDataRoamingnpmnode_modulesyolibrouter.js:8:27)
at ChildProcess.exithandler (child_process.js:275:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at ChildProcess.cp.emit (C:UsershdalaAppDataRoamingnpmnode_modulesyonode_modulescross-spawn-asynclibenoent.js:37:29)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
killed: false,
code: 1,
signal: null,
cmd: 'C:\Windows\system32\cmd.exe /s /c "yo "--version""' }
Found potential issues on your machine :(
+ yo@4.2.0
updated 1 package in 47.053s
C:Windowssystem32>yo doctor
C:UsershdalaAppDataRoamingnpmnode_modulesyonode_modulesyeoman-environmentlibenvironment.js:534
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:UsershdalaAppDataRoamingnpmnode_modulesyolibrouter.js:8:27)
https://help.liferay.com/hc/en-us/articles/360018166591-Creating-Themes
看起来您已经在APPData文件夹下安装了node和npm。请确保您没有在管理员或其他用户许可的文件夹或任何临时文件夹下安装它。建议您将所有这些安装在特定的自定义文件夹路径中,其中npm依赖项安装命令不需要任何权限,这可能会在您的情况下出现问题。
我已经解决了这个问题。你需要安装旧版本的yoaman,
我相信命令是这样的:
npm install -g yo@3.x