简体   繁体   中英

Error in ng serve after installing npm angular/cli

I am a beginner in learning nodejs and angular. I have installed node and created a node project which was working fine. Then I did "npm install -g angular-cli" and after that i did ng new client and inside client when i do "ng serve" i am getting the following error:

The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\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> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\typescript.js:3:17)
    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> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\index.js:9:10)
    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> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-config.js:4:25)
    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> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\tasks\serve.js:11:24)
    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> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\commands\serve.run.js:6:15)
    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 Class.run (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\commands\serve.js:67:16)
    at Class.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\ember-cli\lib\models\command.js:134:17)
    at process._tickCallback (internal/process/next_tick.js:109:7)

You may have older versions.

See the instructions here and see if that helps: https://github.com/angular/angular-cli/wiki/stories-1.0-update

The steps are basically:

  1. Uninstall old version
  2. Update node/npm if necessary
  3. Install new version

The link provides specifics for each of these steps along with appropriate commands.

Here is a simple solution to that and it works like charm.

  • cd into your project directory cd client .

  • Run npm install or yarn install , wait for it to successfully execute

  • Run your ng serve .

I hope this helps and much more easier

Run these two commands:

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

尝试运行这个: npm install --save-dev @angular/cli@latest

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM