Reputation: 7259
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)
> [email protected] install L:\Repos\Temp\TestProject\node_modules\node-sass
> node scripts/install.js
> [email protected] postinstall L:\Repos\Temp\TestProject\node_modules\core-js
> node scripts/postinstall || echo "ignore"
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] 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! [email protected] postinstall: `node scripts/postinstall || echo "ignore"`
npm ERR! spawn bash ENOENT
npm ERR!
npm ERR! Failed at the [email protected] 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
Upvotes: 0
Views: 3170
Reputation: 8243
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)
make sure you have 2 env variables , NVM_HOME and NVM_SYMLINK, and make sure these variables exist in PATH enviroment variable as well.
make sure you installed nodejs as admin.
make sure you can run node
in cmd.
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)
uninstall typescript
and rxjs
for now, to make it more simple.
make sure in all steps, you run command line as administrator.
if above not works, switch to administrator account
and 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.
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
Upvotes: 2