Angular 4 - 尝试升级项目 - "需要一个"错误

时间:2018-04-20 07:36:42

标签: angular upgrade

我尝试在我的项目中安装最新的角度版本,但我得到了大量的"需要一个对等的/你必须自己安装对等依赖项。"错误,我不知道如何解决这个问题

我猜它可能不是一个bug,所以询问有角度的git hub可能会被拒绝

我试过

npm install @angular/core@latest -S

也尝试了

npm install @angular/common@latest -S

仍然一样,

为什么NPM没有处理这个?

npm WARN rollback Rolling back node-pre-gyp@0.6.39 failed (this is probably harmless): EPERM: operation not permitted, rmdir '\node_modules\fsevents\node_modules'
npm WARN @angular/common@5.2.10 requires a peer of rxjs@^5.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/compiler@4.0.0 requires a peer of @angular/core@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/core@5.2.10 requires a peer of rxjs@^5.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/forms@4.0.0 requires a peer of @angular/core@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/forms@4.0.0 requires a peer of @angular/common@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@4.0.0 requires a peer of @angular/core@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-browser@4.0.0 requires a peer of @angular/core@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-browser@4.0.0 requires a peer of @angular/common@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-browser-dynamic@4.0.0 requires a peer of @angular/core@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-browser-dynamic@4.0.0 requires a peer of @angular/common@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/router@4.0.0 requires a peer of @angular/core@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/router@4.0.0 requires a peer of @angular/common@4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-progress-http@0.5.1 requires a peer of @angular/core@^2.3.1 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-cookie@1.2.6 requires a peer of @angular/common@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-cookie@1.2.6 requires a peer of @angular/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@2.0.0 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-accordion@0.0.15 requires a peer of @angular/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-dnd@4.2.0 requires a peer of @angular/core@^2.4.4 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-toasty@4.0.3 requires a peer of @angular/core@^2.4.7 || ^4.0.0 but none is installed. You must install peer dependencies yourself.

感谢

编辑:package.json(^没有更新到最新版本,我尝试手工制作)

"dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@angular/router": "4.0.0",
    "@ngui/tab": "^0.5.0",
    "angular-progress-http": "^0.5.1",
    "angular2-cookie": "1.2.6",
    "angular2-prettyjson": "^2.0.5",
    "chart.js": "^2.6.0",
    "core-js": "2.4.1",
    "es5-shim": "^4.5.9",
    "es6-shim": "^0.35.3",
    "mydaterangepicker": "^4.1.9",
    "ng2-accordion": "0.0.15",
    "ng2-charts": "^1.6.0",
    "ng2-dnd": "^4.2.0",
    "ng2-toasty": "^4.0.3",
    "ng2-validation": "4.1.0",
    "reflect-metadata": "0.1.3",
    "rxjs": "^5.0.1",
    "tinymce": "^4.6.2",
    "ts-md5": "^1.2.0",
    "zone.js": "0.8.5"
  },
  "devDependencies": {
    "@angularclass/hmr": "^1.0.1",
    "@angularclass/hmr-loader": "^3.0.2",
    "@types/jasmine": "^2.5.47",
    "@types/node": "^6.0.72",
    "@types/selenium-webdriver": "2.53.39",
    "angular-router-loader": "^0.6.0",
    "angular2-template-loader": "^0.6.0",
    "autoprefixer": "^6.3.2",
    "awesome-typescript-loader": "^3.1.3",
    "codelyzer": "2.0.0",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.26.1",
    "extract-text-webpack-plugin": "^2.1.0",
    "file-loader": "^0.10.0",
    "html-loader": "^0.4.0",
    "html-webpack-plugin": "^2.28.0",
    "istanbul-instrumenter-loader": "^0.2.0",
    "jasmine-core": "^2.6.1",
    "jasmine-spec-reporter": "^3.2.0",
    "json-loader": "^0.5.4",
    "karma": "1.4.1",
    "karma-chrome-launcher": "^2.1.0",
    "karma-coverage": "^1.0.0",
    "karma-jasmine": "^1.1.0",
    "karma-mocha-reporter": "^2.2.3",
    "karma-remap-istanbul": "0.2.1",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "2.0.2",
    "node-sass": "^4.5.2",
    "null-loader": "0.1.1",
    "on-build-webpack": "^0.1.0",
    "postcss-loader": "^1.1.0",
    "protractor": "^4.0.10",
    "raw-loader": "0.5.1",
    "remap-istanbul": "^0.6.4",
    "rimraf": "^2.6.1",
    "sass-loader": "^6.0.3",
    "shelljs": "^0.7.0",
    "style-loader": "^0.13.0",
    "ts-helpers": "^1.1.1",
    "tslint": "^4.3.1",
    "tslint-loader": "^3.5.3",
    "typedoc": "^0.5.1",
    "typescript": "^2.3.2",
    "url-loader": "^0.5.8",
    "webpack": "2.2.1",
    "webpack-dev-server": "2.3.0",
    "webpack-plugin-hash-output": "^1.3.0"
  }

3 个答案:

答案 0 :(得分:1)

你可以做两件事:

  1. npm install a b c ... a,b c 是您需要更新的对等系列。
  2. 你可以安装一个包含照顾同伴身份的软件包,例如:https://www.npmjs.com/package/npm-install-peers
  3. 如果这两个不起作用,请尝试卸载angular / cli,删除package.jsonpackage-lock.json文件,安装所需的angular / cli版本,然后npm install

答案 1 :(得分:1)

在您的计算机上全局安装最新的Angular CLI。然后转到Angular 4项目的根目录并运行ng update命令。它会正确地将package.json中的依赖项更新为最新的Angular版本。

答案 2 :(得分:1)

经过几天的摆弄,我用CLI重新创建了我的项目,这是解决这个问题的唯一方法......