无法找到API compiler-cli,函数__NGTOOLS_PRIVATE_API_2

时间:2018-06-18 13:41:34

标签: angular angular-cli

我正在尝试恢复旧的Angular项目。

npm-install然后ng-serve之后,我收到以下错误

  

无法找到API compiler-cli,函数__NGTOOLS_PRIVATE_API_2

错误来自@ngtools
包位于..node_modules\@ngtools\webpack\src\ngtools_api.js:8:11)

我的依赖关系看起来如下

  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "angular2-moment": "1.0.0-beta.5",
    "core-js": "^2.4.1",
    "ng2-bootstrap": "^1.1.16",
    "ng2-toastr": "^1.3.0",
    "rxjs": "5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23",
    "moment": "2.15.2",
    "karma-phantomjs-launcher": "^1.0.2"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "angular-cli": "1.0.0-beta.16",
    "bootstrap-sass": "^3.3.7",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "node-sass": "^3.10.1",
    "protractor": "4.0.14",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2",
  }

如果删除节点模块文件夹,我可以从ng -v

获取Angluar版本
angular-cli: 1.0.0-beta.14
node: 9.11.1
os: win32 x64

让这个项目再次运作的最佳方案是什么?

4 个答案:

答案 0 :(得分:0)

涉及几个步骤。我首先将Angular CLI升级到稍微更新的版本。我想只是反复试验。

  1. npm install angular-cli@1.0.0-beta.28.3
  2. npm install @angular/core@2.3.1
  3. 修正了angular-cli.json概述here
  4. 的问题
  5. npm start

答案 1 :(得分:0)

我通过运行以下命令解决了类似的问题:

npm i --save-dev @angular/cli @angular-devkit/build-angular @angular/compiler @angular/compiler-cli

基本上,它会更新所有涉及的参与者。

source

答案 2 :(得分:0)

运行以下命令也对我有用:

npm i --save-dev @angular/cli @angular-devkit/build-angular @angular/compiler @angular/compiler-cli

答案 3 :(得分:0)

我也遇到了这个问题。最终,对我有用的方法或多或少是通过以下步骤删除角度cli并重新安装

db_table = 'sometable'

这帮助了我 来源:how to uninstall angular cli