Liferay 7.1 theme creation: Command failed: C:\Windows\system32\cmd.exe /s /c "yo "--version""

978 Views Asked by At

I'm trying to generate theme using yo theme generator on Lifray 7.1. I followed the steps on the link below, my issue is while running this command "npm install -g yo" it's failing to install yo correctly. I don't know why?! but this is what I'm getting:

    C:\Windows\system32>npm install --global yo
npm WARN deprecated [email protected]: 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 [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead
C:\Users\hdala\AppData\Roaming\npm\yo -> C:\Users\hdala\AppData\Roaming\npm\node_modules\yo\lib\cli.js
C:\Users\hdala\AppData\Roaming\npm\yo-complete -> C:\Users\hdala\AppData\Roaming\npm\node_modules\yo\lib\completion\index.js

> [email protected] postinstall C:\Users\hdala\AppData\Roaming\npm\node_modules\yo
> 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:\Windows\system32\cmd.exe /s /c "yo "--version""
C:\Users\hdala\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\environment.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:\Users\hdala\AppData\Roaming\npm\node_modules\yo\lib\router.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:\Users\hdala\AppData\Roaming\npm\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.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:\Windows\system32\cmd.exe /s /c "yo "--version""
C:\Users\hdala\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\environment.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:\Users\hdala\AppData\Roaming\npm\node_modules\yo\lib\router.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:\Users\hdala\AppData\Roaming\npm\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.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 :(
+ [email protected]
updated 1 package in 47.053s

C:\Windows\system32>yo doctor
C:\Users\hdala\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\environment.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:\Users\hdala\AppData\Roaming\npm\node_modules\yo\lib\router.js:8:27)

https://help.liferay.com/hc/en-us/articles/360018166591-Creating-Themes

2

There are 2 best solutions below

0
sanket patel On

it looks you have installed node and npm under APPData folder. Make sure you do not install it under admin or other user permissioned folder or any temporary folder. It is recommended that you install all this in specific custom folder path where npm dependency installation command does not need any permission which could be issue in your case.

0
hdalang On

I have resolved the issue. You need to install older version of yoaman,

I believe the command is something like this:

npm install -g [email protected]