错误:" @ anuglar / compiler-cli"包没有正确安装

时间:2017-06-20 00:46:30

标签: javascript angular angular-cli

Angular的新手并接管另一位开发人员启动的项目。我已经安装了Angular并且还执行了npm install但是我继续得到" @ anuglar / compiler-cli"包没有正确安装。 这是我到目前为止所做的:

  1. (a)npm install -g typescript,然后(b)npm install - 运气不好" ng"
  2. (a)npm uninstall --save-dev angular-cli(b)npm install --save-dev @ angular / cli @ latest; - 没有运气" ng serve"
  3. 终端错误:

    Error: The "@angular/compiler-cli" package was not properly installed.
        at Object.<anonymous> (/Users/Jack/Documents/Github/t-dashboard/node_modules/@ngtools/webpack/src/index.js:14:11)
        at Module._compile (module.js:573:32)
        at Object.Module._extensions..js (module.js:582:10)
        at Module.load (module.js:490:32)
        at tryModuleLoad (module.js:449:12)
        at Function.Module._load (module.js:441:3)
        at Module.require (module.js:500:17)
        at require (internal/module.js:20:19)
        at Object.<anonymous> (/Users/Jack/Documents/Github/t-dashboard/node_modules/@angular/cli/tasks/eject.js:10:19)
        at Module._compile (module.js:573:32)
        at Object.Module._extensions..js (module.js:582:10)
        at Module.load (module.js:490:32)
        at tryModuleLoad (module.js:449:12)
        at Function.Module._load (module.js:441:3)
        at Module.require (module.js:500:17)
        at require (internal/module.js:20:19)
    

    的package.json

    {
      "name": "genesis-ui",
      "version": "1.5.11",
      "description": "Bootstrap 4 Admin Template",
      "author": "",
      "url": "https://genesisui.com",
      "copyright": "Copyright 2016 creativeLabs Łukasz Holeczek",
      "license": "MIT",
      "angular-cli": {},
      "scripts": {
        "start": "ng serve",
        "lint": "tslint \"src/**/*.ts\"",
        "test": "ng test",
        "pree2e": "webdriver-manager update",
        "e2e": "protractor"
      },
      "private": true,
      "dependencies": {
        "@angular/common": "2.2.3",
        "@angular/compiler": "2.2.3",
        "@angular/core": "2.2.3",
        "@angular/forms": "2.2.3",
        "@angular/http": "2.2.3",
        "@angular/platform-browser": "2.2.3",
        "@angular/platform-browser-dynamic": "2.2.3",
        "@angular/router": "3.2.3",
        "@angular/upgrade": "2.2.3",
        "@types/lodash": "4.14.40",
        "angular-calendar": "0.4.0",
        "angular2-datatable": "0.5.2",
        "angular2-ladda": "^1.0.6",
        "angular2-moment": "^1.1.0",
        "angular2-toaster": "1.0.2",
        "chart.js": "^2.3.0",
        "core-js": "^2.4.0",
        "date-fns": "1.10.0",
        "moment": "^2.17.0",
        "ng2-bootstrap": "^1.1.16",
        "ng2-charts": "^1.4.4",
        "ng2-select": "^1.1.2",
        "ng2-timeago": "^1.0.6",
        "rxjs": "5.0.0-rc.4",
        "ts-helpers": "^1.1.2",
        "zone.js": "0.7.2"
      },
      "devDependencies": {
        "@types/jasmine": "^2.5.37",
        "codelyzer": "1.0.0-beta.4",
        "jasmine-core": "^2.5.2",
        "jasmine-spec-reporter": "2.7.0",
        "karma": "1.3.0",
        "karma-chrome-launcher": "^2.0.0",
        "karma-jasmine": "^1.0.2",
        "karma-remap-istanbul": "^0.2.1",
        "protractor": "4.0.11",
        "ts-node": "1.7.0",
        "tslint": "4.0.2",
        "typescript": "2.3.4"
      }
    }
    

    更新1

    回复的Thx,但仍然遇到同样的问题。 这是我使用的命令:

    1. npm i -S @angular/compiler-cli - &gt;其中在package.json
    2. 中添加了"dependencies":{.., "@angular/compiler-cli": "^4.2.3",...}
    3. npm i -D @angular/cli - &GT;其中添加了"devDependencies":{..., "@angular/cli": "^1.1.2",...}
    4. npm install - &gt;仍然得到同样的错误 - &#34;&#34; @ angular / compiler-cli&#34;包没有正确安装。&#34;
    5. 我以为我尝试将complier-cli安装到devDependency。 npm i -S @angular/compiler-cli - &gt;其中添加了"devDependencies":{..., "@angular/compiler-cli": "^1.1.2",...}然后安装了npm。
    6. 更新2

      npm install上,我在执行过程中看到了一些警告。关于警告的全部意义吗? npm WARN @angular/compiler-cli@4.2.3 requires a peer of @angular/compiler@4.2.3 but none was installed. npm WARN @angular/compiler-cli@4.2.3 requires a peer of @angular/core@4.2.3 but none was installed. npm WARN @angular/core@2.2.3 requires a peer of rxjs@5.0.0-beta.12 but none was installed. npm WARN @angular/core@2.2.3 requires a peer of zone.js@^0.6.21 but none was installed. npm WARN @angular/http@2.2.3 requires a peer of rxjs@5.0.0-beta.12 but none was installed. npm WARN @angular/router@3.2.3 requires a peer of rxjs@5.0.0-beta.12 but none was installed. npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-alpha.26 requires a peer of @angular/core@^4.0.3 but none was installed. npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-alpha.26 requires a peer of @angular/common@^4.0.3 but none was installed. npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-alpha.26 requires a peer of @angular/forms@^4.0.3 but none was installed. npm WARN angular2-ladda@1.2.1 requires a peer of @angular/core@^4.0.0 but none was installed. npm WARN angular2-toaster@1.0.2 requires a peer of rxjs@5.0.0-beta.12 but none was installed. npm WARN codelyzer@1.0.0-beta.4 requires a peer of tslint@^3.9.0 but none was installed. npm WARN ng2-bootstrap@1.6.3 requires a peer of @angular/common@^2.3.1 || >=4.0.0 but none was installed. npm WARN ng2-bootstrap@1.6.3 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0 but none was installed. npm WARN ng2-bootstrap@1.6.3 requires a peer of @angular/core@^2.3.1 || >=4.0.0 but none was installed. npm WARN ng2-bootstrap@1.6.3 requires a peer of @angular/forms@^2.3.1 || >=4.0.0 but none was installed. npm WARN ng2-charts@1.6.0 requires a peer of @angular/common@^2.3.0 || >=4.0.0 but none was installed. npm WARN ng2-charts@1.6.0 requires a peer of @angular/core@^2.3.0 || >=4.0.0 but none was installed. npm WARN ng2-select@1.2.0 requires a peer of @angular/common@^2.3.0 but none was installed. npm WARN ng2-select@1.2.0 requires a peer of @angular/core@^2.3.0 but none was installed.

      仍然是同样的错误。还有其他建议吗?提前谢谢。

5 个答案:

答案 0 :(得分:2)

您缺少编译器cli包,只需重新安装

npm i -S @angular/compiler-cli

你的package.json似乎也缺少dev依赖关系中的角度cli,所以

npm i -D @angular/cli

答案 1 :(得分:1)

包没有数据:

npm i -g npm-check-updates
npm-check-updates -u
npm install

How do I update each dependency in package.json to the latest version?) ......然后

npm install npm -g

https://github.com/Urigo/angular-meteor/issues/1381

感谢大家的帮助!

答案 2 :(得分:0)

dependencies数组

中添加以下依赖项
    "@angular/cli": "1.0.0",

然后重新运行 npm install ng serve

答案 3 :(得分:0)

我对Angular,node.js和npm相对较新,所以我不是说这是一个很好的解决方案,但是我遇到了一个非常类似的错误问题,我解决了以下问题(实验)

"dependencies": {
    "@angular/animations": "^4.1.3",
    "@angular/common": "^4.1.3",
    "@angular/compiler": "^4.1.3",
    "@angular/core": "^4.1.3",
    "@angular/forms": "^4.1.3",
    "@angular/http": "^4.1.3",
    "@angular/platform-browser": "^4.1.3",
    "@angular/platform-browser-dynamic": "^4.1.3",
    "@angular/router": "^4.1.3",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "rxjs": "^5.4.1",
    "webpack": "^2.6.1",
    "zone.js": "^0.8.12"
}
    "devDependencies": {
    "@angular/cli": "1.1.1",
    "@angular/compiler-cli": "^4.1.3",
    "@types/jasmine": "2.5.51",
    "@types/node": "~7.0.29",
    "codelyzer": "~3.0.1",
    "jasmine-core": "~2.6.3",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.3.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~3.0.6",
    "tslint": "~5.4.3",
    "typescript": "~2.3.4"
}
  1. 我删除了node_modules
  2. 的内容
  3. 运行失败的npm install
  4. 运行npm outdated,其中显示所有依赖项为MISSING
  5. 已安装最新rxjs(从5.4.0升级)
  6. 手动匹配版本(4.1.3)
  7. 安装了所有@angular dev依赖项
  8. 按此顺序安装了其余的dev依赖项:zone.jscore-jswebpackbootstrap也匹配版本(看起来像顺序很重要)
  9. 运行显示所有已安装软件包的npm outdated
  10. 运行失败的ng build
  11. 运行npm r @angular/compiler-cli -D将其从dev依赖项中删除。不得不做两次,因为第一次失败,但似乎(失败的时间)在node_modules
  12. 中添加了许多依赖项
  13. 运行npm i @angular/compiler-cli@4.1.3 -D将其添加到我的开发依赖项
  14. 成功运行ng build

答案 4 :(得分:0)

  

我遇到了相同的错误“ @ angular / compiler-cli”软件包是   没有正确安装。

这是我尝试过的几件事

1.Remove node_modules and run npm install
2.Installing latest version of typescript
3.Re-install cli npm install --save-dev @angular/cli@latest