Angular2 CLI error "@angular/compiler-cli" package was not properly installed

Foo Barazz picture Foo Barazz · Mar 21, 2017 · Viewed 75.3k times · Source

I'm working an Angular 2 project. Now trying to install Angular CLI within the current project with the following

npm install --save-dev @angular/cli@latest
npm install

Problem is when running ng serve I receive error

The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
    at Object.<anonymous> (/myng2project/node_modules/@ngtools/webpack/src/index.js:14:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/myng2project/node_modules/@angular/cli/tasks/eject.js:10:19)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

Answer

ruzenhack picture ruzenhack · Mar 30, 2017

I had the same problem. I resolved it following the "Updating Angular CLI" process in the npm @angular/cli page, that is:

1. Uninstall and clean (global)

rm -rf node_modules dist
npm uninstall -g @angular/cli
npm cache clean

2. Reinstall and play (global)

npm install -g @angular/cli@latest
npm install
ng serve

This worked for me.