为什么我的Angular CLI无法找到模块'@ angular / compiler-cli / ngcc'?

时间:2019-09-24 06:41:25

标签: angular angular-compiler angular-pwa

通过ng add @angular/pwa --project myProjectName成功安装PWA组件以使Angular应用成为 Progressive Web应用后,我似乎无法再启动我的应用。

当我尝试通过ng serve -o启动我的应用程序时,出现以下错误消息:

  

发生未处理的异常:找不到模块'@ angular / compiler-cli / ngcc'
      有关更多详细信息,请参见“ /tmp/ng-JO4KFv/angular-errors.log”。

我试图卸载Angular CLI并重新安装它的最新版本according to the instructions here,但这根本没有帮助。

我该如何解决此问题并使它正常工作?

在我的Angular应用程序环境下找到: my Angular Environment

{
  "name": "myProjectName",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.2",
    "@angular/animations": "^6.1.0",
    "@angular/cdk": "^6.2.1",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/material": "^6.2.1",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/platform-server": "^6.1.0",
    "@angular/router": "^6.1.0",
    "@jaspero/ng-alerts": "^0.1.1",
    "@jaspero/ng2-confirmations": "^0.3.3",
    "@jaspero/ng2-select": "^0.1.2",
    "@material/top-app-bar": "^3.2.0",
    "@ng-bootstrap/ng-bootstrap": "^2.0.0",
    "@ngx-loading-bar/core": "^1.2.0",
    "angular-calendar": "^0.26.4",
    "angular2-image-zoom": "^1.2.1",
    "angular2-notifications": "^0.9.7",
    "axios": "^0.18.0",
    "bootstrap": "^4.0.0",
    "core-js": "^2.5.4",
    "date-fns": "^1.29.0",
    "echarts": "^4.1.0",
    "jquery": "^3.3.1",
    "moment": "^2.22.0",
    "ng-sidebar": "^7.0.1",
    "ng-spin-kit": "^5.1.1",
    "ng2-archwizard": "^2.1.0",
    "ng2-search-filter": "^0.4.7",
    "ng2-spin-kit-new": "^1.0.3",
    "ng6-toastr-notifications": "^1.0.4",
    "ngx-avatar": "^2.9.0",
    "ngx-bootstrap": "^2.0.5",
    "ngx-cookie-service": "^1.0.10",
    "ngx-drag-scroll": "^1.7.3",
    "ngx-echarts": "^4.0.0",
    "ngx-pagination": "^4.1.0",
    "rxjs": "^6.2.0",
    "rxjs-compat": "^6.2.0",
    "socket.io-client": "^2.0.3",
    "sockjs-client": "^1.1.5",
    "stompjs": "^2.3.3",
    "sweetalert2": "^7.12.15",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.7.5",
    "@angular/cli": "^6.2.1",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "6.0.4",
    "@types/echarts": "0.0.13",
    "@types/googlemaps": "^3.30.8",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.0",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "2.9.2"
  }
}

2 个答案:

答案 0 :(得分:0)

尝试一下

尝试删除该"angular/cli": "1.0.0-beta.28.3",在 devDependencies 中它是无用的,并添加它而不是"@angular/compiler-cli": "^2.3.1",(因为它是当前版本,否则可以通过添加它npm i --save-dev @angular/compiler-cli),然后在您的根应用文件夹中运行以下命令:

1. rm -r node_modules (or delete your node_modules folder manually)
2. npm cache clean --force (doesnt not work in npm v5)
3. npm install

答案 1 :(得分:0)

您似乎已更新了GLOBAL的角度cli(与8.3.5相比),但是依存关系为in your project are very OLD.

尝试在项目内部运行ng update --force或遵循本指南

https://update.angular.io/

希望对您有帮助!