【问题标题】:Cannot find module @angular/compiler-cli/src/tooling找不到模块@angular/compiler-cli/src/tooling
【发布时间】:2020-11-21 10:06:51
【问题描述】:

我正在尝试使用 npm run start 命令运行 Angular 项目,但出现此错误:

找不到模块@angular/compiler-cli/src/tooling`。

下面是ng --version的结果:

Angular CLI: 7.0.7
Node: 12.14.1
OS: win32 x64
Angular: 7.0.4

package.json

@angular-devkit/architect         0.10.7
@angular-devkit/build-angular     0.1000.4
@angular-devkit/build-optimizer   0.1000.4
@angular-devkit/build-webpack     0.1000.4
@angular-devkit/core              7.0.7
@angular-devkit/schematics        7.0.7
@angular/cdk                      7.3.2
@angular/cli                      7.0.7
@angular/compiler-cli             7.2.16
@angular/material                 7.3.2
@ngtools/webpack                  10.0.4
@schematics/angular               7.0.7
@schematics/update                0.10.7
rxjs                              6.3.3
typescript                        3.1.6
webpack                           4.43.0

【问题讨论】:

  • 你有没有在 npm run start 之前运行 npm install ?
  • @NaveenMotwani-AIS 我运行 npm ci 因为我需要确保从 packge-lock.json 下载包
  • 好的,你也少了一些包,看看我的回答

标签: angular angular7 node-modules


【解决方案1】:

将 angular/cli 更新到最新版本

1- npm uninstall -g angular/cli
2- npm install -g @angular/cli@latest

更新项目依赖

1- rm -rf node_modules (or delete your node_modules folder manually)
2- npm cache clean (npm > v5 add --force so: npm cache clean --force)
3- npm install --save-dev @angular/cli@latest
4- npm install

【讨论】:

    【解决方案2】:

    我能够通过使用npm cach clean --force 清除缓存并使用npm init 重新安装依赖项来解决它

    【讨论】:

      【解决方案3】:
      1. 删除节点模块
      2. package.json 中更新 @angular/compiler-cli": "^10.2.0
      3. 确保您在 package.json 中拥有正确的节点 @types/node": "^14.14.2
      4. 终于npm install

      这解决了我的错误

      【讨论】:

        【解决方案4】:

        我认为您缺少 Angular 中的一些包,例如 @angular/core 请比较您的 package.json 文件并相应添加。

        还有一个提示,删除 package.lock.json 文件,然后运行 ​​npm install。

        【讨论】:

        • 我应该在哪里比较这些?我应该打开和比较什么文件?是packge-lock.json?
        【解决方案5】:

        @ngtools/webpack 应该是与其他包版本兼容的。

        "@ngtools/webpack": "7.3.9"
        

        应该有帮助

        【讨论】:

          猜你喜欢
          • 2021-06-05
          • 2020-05-25
          • 1970-01-01
          • 2018-12-11
          • 1970-01-01
          • 2018-02-04
          • 1970-01-01
          • 2017-07-23
          • 2020-05-03
          相关资源
          最近更新 更多