3
votes

I'm using Angular4 with Angular/CLI 1.2.1. I'm able to initialize fine and use ng serve to run the application locally. However, after pushing to a remote git repo and then doing pulling my work down on a different machine - I get errors.

Steps to Recreate
1. Pull project created using Angular CLI from remote git repo.
2. NPM install.
3. ng serve.

Error Messages

ERROR in D:/application/src/app/app.component.ts (1,27): Cannot find module '@angular/core'.

ERROR in D:/application/src/app/app.component.ts (8,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

ERROR in D:/application/src/app/app.module.ts (1,31): Cannot find module '@angular/platform-browser'.

ERROR in D:/application/src/app/app.module.ts (2,26): Cannot find module '@angular/core'.

ERROR in D:/application/src/app/app.module.ts (16,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

ERROR in D:/application/src/main.ts (1,32): Cannot find module '@angular/core'.

ERROR in D:/application/src/main.ts (2,40): Cannot find module '@angular/platform-browser-dynamic'.

ERROR in Could not resolve module @angular/core

ERROR in D:/application/src/main.ts (1,32): Cannot find module '@angular/core'.

ERROR in D:/application/src/main.ts (2,40): Cannot find module '@angular/platform-browser-dynamic'.

ERROR in D:/application/src/app/app.module.ts (1,31): Cannot find module '@angular/platform-browser'.

ERROR in D:/application/src/app/app.module.ts (2,26): Cannot find module '@angular/core'.

ERROR in D:/application/src/app/app.module.ts (16,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

ERROR in D:/application/src/app/app.component.ts (1,27): Cannot find module '@angular/core'.

ERROR in D:/application/src/app/app.component.ts (8,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

webpack: Failed to compile.

NPM Install Output

npm WARN prefer global [email protected] should be installed with -g

[email protected] install D:\application\node_modules\node-sass node scripts/install.js

Cached binary found at C:\Users\user\AppData\Roaming\npm-cache\node-sass\4.5.3\win32-x64-48_binding.node

[email protected] postinstall D:\application\node_modules\node-sass node scripts/build.js

Binary found at D:\application\node_modules\node-sass\vendor\win32-x64-48\binding.node Testing binary Binary is fine

...proceeds to install without error (including @angular/core and other packages).

3
The errors indicate that angular is missing in your node_modules directory (or that node_modules itself is missing). What is the output of npm install? - Hendrik Brummermann
Added NPM Install output above. No errors. - starno
Update your angular libraries to latest and try running ng serve after that - pritesh

3 Answers

0
votes

Easy way to remove node_modules folder from your angular project hierarchy and use to re install all the packages by using npm install

0
votes

try Deleting package-lock.json file and then install node_modules npm install

0
votes

go to the project folder in your terminal and type npm rebuild.

If your node_modules doesn't exist or doesn't have all the dependencies needed, delete and run npm install.

Refer to this thread: How to run "npm install" to create node_modules folder for an older Angular project?