DEV Community

brianreinhold
brianreinhold

Posted on

npm install fails, ng serve works

I have been tasked with fixing and updating a complex Angular Cli project that is basically ancient. Everything for me is new here; javascript, typescript, node JS (npm), and of course, Angular itself.
After a week or two I have obtained some familiarity thanks to many excellent tutorial videos on You Tube.

But I have come across a perplexing problem I do not understand and cannot fix. I have the following for versions:

Angular CLI: 14.2.0
Node: 14.18.1
Package Manager: npm 6.14.18
OS: win32 x64

Angular: 7.2.16
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.10.7
@angular-devkit/build-angular   0.10.7
@angular-devkit/core            0.3.2
@angular-devkit/schematics      14.2.0
@angular/cdk                    7.3.7
@angular/cli                    14.2.0
@angular/flex-layout            7.0.0-beta.19
@angular/material               7.3.7
@schematics/angular             14.2.0
rxjs                            6.5.5
typescript                      3.1.6
Enter fullscreen mode Exit fullscreen mode

When I run npm install I get the following errors:

gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe ENOENT
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:274:19)
gyp ERR! stack     at onErrorNT (internal/child_process.js:469:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:82:21)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "C:\\Users\\brian\\AppData\\Local\\nvs\\node\\14.18.1\\x64\\node.exe" "E:\\projects\\exchangex\\node_modules\\@angular-devkit\\build-angular\\node_modules\\node-gyp\\bin\\node-gyp
.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:\projects\exchangex\node_modules\@angular-devkit\build-angular\node_modules\node-sass
gyp ERR! node -v v14.18.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
Build failed with error code: 7
Enter fullscreen mode Exit fullscreen mode

However, ng serve works!

I spent a week trying to get another version of node-gyp to be used, always failing and never tried ng serve because I assumed it would not work.

The goal is to update this project to the current versions of Angular cli / nodeJs but I am at a loss to understand the failure of 'npm install' and the success of 'ng serve'

What am I missing?

Top comments (0)