【问题标题】:ng serve build error after npm installnpm install 后 ng serve 构建错误
【发布时间】:2017-02-12 16:28:41
【问题描述】:

删除node_modules 目录并使用npm install 新建目录后,我在使用cmd ng serve 的angular2 应用程序中遇到以下错误。

Error: Cannot find module 'common-tags'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/angular-cli/models/config.js:8:21)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)

还有npm install common-tags手动添加也行不通

【问题讨论】:

  • 升级到最新版本的 angular-cli 后你是否面临这个问题?
  • 我将我的项目移到了一个新的存储库中。不幸的是,我也提交了 node_modules。删除文件夹,运行npm install,但安装包后应用程序不会以ng serve 启动 - 错误如上。
  • 看起来你还没有全局安装 angular-cli。按照这里提到的步骤github.com/angular/angular-cli。参考Updating angular-cli部分
  • ......请杀了我。当然运行ng serve 需要先运行npm start。不是 angular-cli 或 smh 只是想通了,因为 ngs 都没有工作。
  • 实际上我遇到了一些问题,但有不同的解决方案。删除 .lock 文件和 node_modules 并重新安装依赖项后,它再次工作

标签: node.js angular npm


【解决方案1】:

看来您应该更新 angular-cli 并清理缓存

npm uninstall -g @angular/cli
npm cache clean --force 
npm install -g @angular/cli@latest
npm install

【讨论】:

  • 这为我解决了问题。注意:我也事先安装了 node-gyp。
猜你喜欢
  • 1970-01-01
  • 2017-12-08
  • 2021-05-10
  • 2018-01-22
  • 2017-07-19
  • 2014-07-19
  • 1970-01-01
  • 2018-07-04
  • 2017-07-07
相关资源
最近更新 更多