0

I am using Angular CLI version 7.3.9 because I can't upgrade to 8.3.2 (I'm assuming the error I get from trying to upgrade Angular CLI is the same issue). When I try to create a new project I'm getting an NPM exception. I've tried clearing the npm cache and updating all of the globally installed packages. Some packages error out with similar errors, other seem to work fine.

This is only affecting one machine. I've tried uninstalling and reinstalling @angular/cli, uninstalling and reinstalling node, and trying both node 10 and 12. None have solved the error.

What are my options as far as troubleshooting NPM install errors? What can I try to fix this issue below? Is there anywhere I should look for better answers?

When I run ng version I get the following output:

Angular CLI: 7.3.9
Node: 10.16.3
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.13.9
@angular-devkit/core         7.3.9
@angular-devkit/schematics   7.3.9
@schematics/angular          7.3.9
@schematics/update           0.13.9
rxjs                         6.3.3
typescript                   3.2.4

When I run the command ng new TestProject I get the following output:

PS L:\Repos\Temp> ng new TestProject
? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? Less   [ http://lesscss.org
     ]
CREATE TestProject/angular.json (3940 bytes)
CREATE TestProject/package.json (1311 bytes)
CREATE TestProject/README.md (1028 bytes)
CREATE TestProject/tsconfig.json (435 bytes)
CREATE TestProject/tslint.json (1621 bytes)
CREATE TestProject/.editorconfig (246 bytes)
CREATE TestProject/.gitignore (629 bytes)
CREATE TestProject/src/favicon.ico (5430 bytes)
CREATE TestProject/src/index.html (298 bytes)
CREATE TestProject/src/main.ts (372 bytes)
CREATE TestProject/src/polyfills.ts (2841 bytes)
CREATE TestProject/src/styles.less (80 bytes)
CREATE TestProject/src/test.ts (642 bytes)
CREATE TestProject/src/browserslist (388 bytes)
CREATE TestProject/src/karma.conf.js (1024 bytes)
CREATE TestProject/src/tsconfig.app.json (166 bytes)
CREATE TestProject/src/tsconfig.spec.json (256 bytes)
CREATE TestProject/src/tslint.json (244 bytes)
CREATE TestProject/src/assets/.gitkeep (0 bytes)
CREATE TestProject/src/environments/environment.prod.ts (51 bytes)
CREATE TestProject/src/environments/environment.ts (662 bytes)
CREATE TestProject/src/app/app-routing.module.ts (245 bytes)
CREATE TestProject/src/app/app.module.ts (393 bytes)
CREATE TestProject/src/app/app.component.html (1152 bytes)
CREATE TestProject/src/app/app.component.spec.ts (1110 bytes)
CREATE TestProject/src/app/app.component.ts (216 bytes)
CREATE TestProject/src/app/app.component.less (0 bytes)
CREATE TestProject/e2e/protractor.conf.js (752 bytes)
CREATE TestProject/e2e/tsconfig.e2e.json (213 bytes)
CREATE TestProject/e2e/src/app.e2e-spec.ts (640 bytes)
CREATE TestProject/e2e/src/app.po.ts (251 bytes)

> node-sass@4.12.0 install L:\Repos\Temp\TestProject\node_modules\node-sass
> node scripts/install.js


> core-js@2.6.9 postinstall L:\Repos\Temp\TestProject\node_modules\core-js
> node scripts/postinstall || echo "ignore"

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.12.0 (node_modules\node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.12.0 install: `node scripts/install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: spawn bash ENOENT

npm ERR! file bash
npm ERR! path bash
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn bash
npm ERR! core-js@2.6.9 postinstall: `node scripts/postinstall || echo "ignore"`
npm ERR! spawn bash ENOENT
npm ERR!
npm ERR! Failed at the core-js@2.6.9 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\<USER>\AppData\Roaming\npm-cache\_logs\2019-08-30T19_06_06_818Z-debug.log
Package install failed, see above.

The contents of the log above can be found here: https://gist.github.com/joecoolish/ff0ffdb7eb583ef5b18146ca2e456c2c

joe_coolish
  • 7,201
  • 13
  • 64
  • 111
  • maybe helpfull: https://stackoverflow.com/a/52247173/4718434 – yaya Sep 02 '19 at 16:12
  • 1
    @yaya, I originally had that same thought. I am getting the error trying to install global packages. I've completely uninstalled node and deleted all the roaming app data folders, and I still am getting the error :/. Super annoying – joe_coolish Sep 02 '19 at 16:22
  • did you tried downgrading node too? also try creating project in c drive, instead of L. – yaya Sep 02 '19 at 17:26
  • also did you completely uninstall node and npm? i mean, in my machine (windows) there is 2 folder, one is in appdata, and one is in program files. also i think you can search for npm cache folder path and delete it manually. – yaya Sep 02 '19 at 17:33
  • Yep. I went from node 12 to node 10, I tried creating a new project on the C drive, and I just uninstalled, deleted every mention of NPM on my c:\ drive (I found some I missed last time, so I was hopeful), Reinstalled node 10 w/ npm 6.9, and the error is still there. – joe_coolish Sep 03 '19 at 03:13
  • i wanted to put it as a comment, but since it was long, i posted an answer. – yaya Sep 03 '19 at 05:47

1 Answers1

2

Tl;dr: in windows often using Git bash instead of normal command line solves the issue. in other platforms, there may be couple of reasons. (read below).

First try clearing npm cache and downgrading node as described here: link

you get this error when ng tries to execute node and also when installing node-sass. both seems to be permission(security) problem, or node environment variable issues. So try these :

1. use Git bash instead of cmd (FIRST TRY THIS, It often solves the issue)

  1. make sure you have 2 env variables , NVM_HOME and NVM_SYMLINK, and make sure these variables exist in PATH enviroment variable as well.

  2. make sure you installed nodejs as admin.

  3. make sure you can run node in cmd.

  4. uninstall angular cli and install it with --unsafe-perm flag (again as admin) (like this: https://github.com/Alex-Rose/fb-messenger-cli/issues/94#issuecomment-333047050)

  5. uninstall typescript and rxjs for now, to make it more simple.

  6. make sure in all steps, you run command line as administrator.

  7. if above not works, switch to administrator accountand try there.

links related to errors you get :

https://github.com/Medium/phantomjs/issues/765

https://github.com/sass/node-sass/issues/2544

Also if this didn't solved the issue, try https://stackoverflow.com/a/27883443/4718434 to log more details about spawn ENOENT error.

EDIT

It appears that the package that is failing post install is simply executing the echo command. Verify that your system can handle the echo command and if not, you can also write a simple echo.cmd script and put it into windows/system32

yaya
  • 7,675
  • 1
  • 39
  • 38
  • So git bash worked... Why would git bash work when CMD/PowerShell not work? – joe_coolish Sep 03 '19 at 11:54
  • @joe_coolish actually i tested it in cmd. git bash has some commands that linux has. did you try also in cmd/powershell? – yaya Sep 03 '19 at 11:57
  • I tried in all 3 and only git bash worked. I looked at the postinstall.js files that are failing, and the commands are basically "echo" commands, which don't resolve in cmd/powershell. – joe_coolish Sep 03 '19 at 12:03
  • 1
    my cmd has `echo` command. you can also write a simple `echo.cmd` script and put it into `windows/system32` – yaya Sep 03 '19 at 12:07
  • Ha! That worked! CMD couldn't run the command Echo, so any post install script that echoed, would fail! Could you update your answer so I can give you the bounty? – joe_coolish Sep 03 '19 at 12:13
  • glad it worked. i'm not sure how to update my answer, cause i don't know what steps you did to make it work. if it's ok, suggest an edit and i'll approve it. – yaya Sep 03 '19 at 12:16
  • Done, I have to wait 3 hours to give you the bounty, I'll try again later – joe_coolish Sep 03 '19 at 12:20
  • no problem, thanks. was the `echo` the only problem? (did you try any of steps in answer?) thats funny because echo is part of cmd, do you have any idea why your windows doesn't have echo command? – yaya Sep 03 '19 at 12:22
  • Yep, it was just echo. I have no idea why it wasn't working. The computer that was not working is a shared computer so you never know! It was the try in git bash that was the breakthrough – joe_coolish Sep 03 '19 at 12:24
  • :D so perhas admin turned it off (or it needs admin privilege). glad it solved. – yaya Sep 03 '19 at 12:25
  • For me on Windows 10 using git bash solved the problem. – Milan Tenk Nov 23 '19 at 09:59
  • 1
    @tenkmilan Thanks. since the person who asked the answer also fixed his issue with git, i moved it at first of list. – yaya Nov 29 '19 at 10:17