0

D:\CDAC Project\Nodejs>npm install -g @angular/cli

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
C:\Users\Akash Tawade\AppData\Roaming\npm\ng -> C:\Users\Akash Tawade\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

> @angular/cli@10.0.8 postinstall C:\Users\Akash Tawade\AppData\Roaming\npm\node_modules\@angular\cli
> node ./bin/postinstall/script.js

'node' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @angular/cli@10.0.8 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @angular/cli@10.0.8 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Akash Tawade\AppData\Roaming\npm-cache\_logs\2020-08-31T07_54_44_998Z-debug.log

I had went through many articles to solve this error as well as you tube videos but it's not working.

3 Answers3

1

Just add the following tags to your command:

npm install -g @angular/cli --unsafe-perm=true --allow-root
Riccardo
  • 1,083
  • 2
  • 15
  • 25
0

Here's the solution that I found

Solution:-

Step 1: Uninstall angular/cli if it is already install

npm uninstall -g @angular/cli

Step 2: Try to delete folder of following if it is still present

C:\Users\Akash Tawade\AppData\Roaming\npm\node_modules\@angular

Step 3: Try to delete file 'ng' and 'ng.cmd' if it is present.You will find these file inside below folder.

C:\Users\Akash Tawade\AppData\Roaming\npm\ng 

C:\Users\Akash Tawade\AppData\Roaming\npm\ng.cmd

Step 4: Install angular/cli globally again

npm install -g @angular/cli
0

I got the same error when running the same command: npm i -g @angular/cli.

Node.js was installed by my company.

PowerShell recognizes node and npm commands, but CMD does not.

So I can run npm command from PS, but there is a moment when it tries to execute a command like this:

...\cmd.exe /c node ./bin/postinstall/script.js

and then I get the error:

'node' is not recognized as an internal or external command, operable program or batch file.

My problem was a single quote sign " in environment variable PATH which broke half of PATH's paths that were after the quote sign.

I would just fix the variable, even if I had to use registry editor, but this time it is my company's laptop without admin access so the only quick fix for me is to use https://cmder.net

Cmder seems to correct the environment variable PATH.

It removed quote sign and it understands node and npm commands.

And, yes, I just installed Angular cli using Cmder.

sicko
  • 157
  • 3
  • 4