麻烦升级角2至4中NPM(Trouble upgrading Angular 2 to 4 in n

2019-09-29 07:19发布

我无法在NPM升级角2〜4。 下面是我的package.json和我运行在终端NPM更新--save,但是的package.json不会更新到最新的4角,只是保持不变。 我做错了吗?

{
  "name": "todo1",
  "version": "0.0.0",
  "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.4.7",
    "@angular/compiler": "^2.4.7",
    "@angular/compiler-cli": "^2.4.7",
    "@angular/core": "^2.2.3",
    "@angular/flex-layout": "2.0.0-beta.4",
    "@angular/forms": "^2.4.7",
    "@angular/http": "^2.4.7",
    "@angular/material": "^2.0.0-beta.2",
    "@angular/platform-browser": "^2.4.7",
    "@angular/platform-browser-dynamic": "^2.4.7",
    "@angular/router": "^3.4.7",
    "@types/jasmine": "^2.5.41",
    "angular2-color-picker": "^1.3.0",
    "angular2-jwt": "^0.1.28",
    "angular2-uuid": "^1.1.1",
    "core-js": "^2.4.1",
    "jasmine-spec-reporter": "^2.7.0",
    "karma": "^1.4.1",
    "lodash": "^4.17.4",
    "protractor": "^4.0.14",
    "rxjs": "^5.1.0",
    "ts-helpers": "^1.1.1",
    "ts-node": "^1.7.3",
    "tslint": "^4.1.1",
    "tslint-loader": "^3.3.0",
    "webdriver-manager": "^10.3.0",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-beta.31",
    "@angular/compiler-cli": "^2.2.3",
    "@types/jasmine": "^2.5.38",
    "@types/lodash": "^4.14.52",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.22-1",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "^2.5.2",
    "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",
    "protractor": "^4.0.9",
    "ts-node": "^1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3",
    "webdriver-manager": "^10.2.5"
  }
}

Answer 1:

我已经更新我的应用程序使用由角团队创建此工具的角度CLI创建。

https://angular-update-guide.firebaseapp.com/



Answer 2:

如果你是在Windows上使用以下命令故宫

npm install @angular/common@next @angular/compiler@next @angular/compiler-cli@next @angular/core@next @angular/forms@next @angular/http@next @angular/platform-browser@next @angular/platform-browser-dynamic@next @angular/platform-server@next @angular/router@next @angular/animations@next --save

否则,您可以手动更新与依赖关系的package.json文件,然后运行安装NPM



Answer 3:

npm update不更新主要版本 。 这是该版本的第一个数字,它仅更新次要和补丁版本。 为此--save并没有真正做多,如果你已经是最新的次要版本。

您可以使用

npm install @angular/common@latest ...等

或者只是做一个快速的搜索和替换你的内部package.json^2.4.7^4.0.0 。 而且不要忘记更新路由器^4.0.0为好,因为他们现在对齐版本:)



文章来源: Trouble upgrading Angular 2 to 4 in npm
标签: angular