2

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.
Nanetta
  • 101
  • 13
  • 1
    Try upgrading to node v12.4 . Angular 8 requires latest version of node. – Bogdan B Jun 10 '19 at 09:32
  • @Bogdan B I tried with the latest version the problem still remaining – Nanetta Jun 10 '19 at 09:44
  • 1
    i am able to install with node v8.11 – saketh Jun 10 '19 at 09:46
  • 1
    try `npm cache clear ` and run `npm i -g @angular/cli` command – saketh Jun 10 '19 at 09:47
  • 1
    i believe file path is missing in environment variables check this https://stackoverflow.com/questions/27344045/installing-node-js-and-npm-on-windows-10 – saketh Jun 10 '19 at 10:01
  • 1
    this might help https://stackoverflow.com/questions/49302406/prefix-g-is-not-recognized-as-an-internal-or-external-command-issue-on-durin?rq=1 – saketh Jun 10 '19 at 10:04
  • I am able to install cli with node 10.14.1, probably problem is not node version – vanrado Jun 10 '19 at 11:17
  • 1
    @rose, If @saketh advice will not work, try to run `npm cache clean` (according to npm [troubleshooting](https://docs.npmjs.com/common-errors#random-errors)) and then try to install again with your commands. – vanrado Jun 10 '19 at 11:31
  • I tried all these commands but the problem is still remaining.I can't find what is the exact issue. – Nanetta Jun 10 '19 at 11:48
  • is the type of processor a factor, when working with nodes and npm? – Nanetta Jun 10 '19 at 12:01
  • 1
    @rose have you tried removing my files from recovery setting. As far as i know processor won't be a problem in recognizing the command the only problem is with the environment variables – saketh Jun 10 '19 at 13:01
  • Thank you all for helping me :) . – Nanetta Jun 12 '19 at 10:15

1 Answers1

2

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.

Nanetta
  • 101
  • 13