问题
I am trying to install @angular/cli using the npm install -g @angular/cli.
But this try provides some error messages.
my node and npm versions are mentioned below,
C:\WINDOWS\system32>node -v
v 12.4.0
C:\WINDOWS\system32>npm -v
'CALL "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g is not recognized as an internal or external command,
operable program or batch file.
6.9.0
I am using Windows10 operating system
When I am trying to install angular cli I got the following error messages
C:\WINDOWS\system32>npm install -g @angular/cli
'CALL "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\me\AppData\Roaming\npm\ng -> C:\Users\me\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
> @angular/cli@8.0.2 postinstall C:\Users\me\AppData\Roaming\npm\node_modules\@angular\cli
> node ./bin/postinstall/script.js
npm ERR! file C:\WINDOWS\system32\cmd.exe;
npm ERR! path C:\WINDOWS\system32\cmd.exe;
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn C:\WINDOWS\system32\cmd.exe;
npm ERR! @angular/cli@8.0.2 postinstall: `node ./bin/postinstall/script.js`
npm ERR! spawn C:\WINDOWS\system32\cmd.exe; ENOENT
npm ERR!
npm ERR! Failed at the @angular/cli@8.0.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
回答1:
In this case the error occurs because of the semicolon at the end of the path in System variables.
ComSpec path C:\Windows\System32\cmd.exe;
Removing semicolon from the path works for me.
来源:https://stackoverflow.com/questions/56523652/unable-to-install-angular-cli