安装npm angular / cli后ng服务出错

时间:2017-07-05 07:08:00

标签: node.js angular npm

我是学习nodejs和angular的初学者。我已经安装了节点并创建了一个工作正常的节点项目。然后我做了#34; npm install -g angular-cli"然后我做了新客户和内部客户,当我做" ng serve"我收到以下错误:

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)

4 个答案:

答案 0 :(得分:0)

您可能有旧版本。

请参阅此处的说明,看看是否有帮助:https://github.com/angular/angular-cli/wiki/stories-1.0-update

步骤基本上是:

  1. 卸载旧版本
  2. 如有必要,更新节点/ npm
  3. 安装新版本
  4. 该链接提供了每个步骤的详细信息以及相应的命令。

答案 1 :(得分:0)

这是一个简单的解决方案,它就像魅力一样。

  • cd进入项目目录cd client

  • 运行npm installyarn install,等待其成功执行

  • 运行您的ng serve

我希望这会有所帮助并且更加轻松

答案 2 :(得分:0)

运行以下两个命令:

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

答案 3 :(得分:0)

尝试运行此命令:npm install --save-dev @ angular / cli @ latest