我正在遵循官方文档进行升级。
此步骤已完成,没有任何错误。
ng update @angular/core@8 @angular/cli@8
下一步失败。
ng update @angular/core @angular/cli
The installed Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 45 dependencies.
Fetching dependency metadata from registry...
Package "@angular/core" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/animations" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/compiler" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/forms" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/common" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/platform-browser" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/compiler-cli" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/router" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/platform-browser-dynamic" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@ngtools/webpack" has an incompatible peer dependency to "typescript" (requires ">=3.4 < 3.6", would install "3.7.5").
Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
我检查了node_modules并安装了正确版本的tslib。 我手动添加了tslib条目,然后运行npm install来查看错误是否消失。
"dependencies": {
"@angular/animations": "^8.2.14",
"@angular/common": "^8.2.14",
"@angular/compiler": "^8.2.14",
"@angular/core": "^8.2.14",
"@angular/forms": "^8.2.14",
"@angular/language-service": "^8.2.14",
"@angular/platform-browser": "^8.2.14",
"@angular/platform-browser-dynamic": "^8.2.14",
"@angular/router": "^8.2.14",
"@ng-bootstrap/ng-bootstrap": "^5.3.0",
"classlist.js": "^1.1.20150312",
"core-js": "^3.6.4",
"npm": "^6.13.7",
"rxjs": "^6.5.4",
"web-animations-js": "^2.3.2",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/architect": "^0.803.25",
"@angular-devkit/build-angular": "^0.803.25",
"@angular-devkit/build-optimizer": "^0.803.25",
"@angular-devkit/build-webpack": "^0.803.25",
"@angular-devkit/core": "^8.3.25",
"@angular-devkit/schematics": "^8.3.25",
"@angular/cli": "^8.3.25",
"@angular/compiler-cli": "^8.2.14",
"@ngtools/webpack": "^8.3.25",
"@schematics/angular": "^8.3.25",
"@schematics/update": "^0.803.25",
"@types/jasmine": "^3.5.4",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^12.12.27",
"tslib": "^1.10.0",
"codelyzer": "^5.2.1",
"jasmine-core": "^3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.5.2",
"protractor": "^5.4.3",
"rxjs-tslint": "^0.1.7",
"ts-node": "^8.6.2",
"tslint": "^5.20.1",
"typescript": "~3.4",
"webpack": "^4.41.6",
"webpack-dev-server": "^3.10.3"
}
ng v输出
Angular CLI: 8.3.25
Node: 12.13.0
OS: win32 x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.803.24
@angular-devkit/build-angular 0.803.25
@angular-devkit/build-optimizer 0.803.24
@angular-devkit/build-webpack 0.803.25
@angular-devkit/core 8.3.24
@angular-devkit/schematics 8.3.24
@angular/cli 8.3.25
@ngtools/webpack 8.3.24
@schematics/angular 8.3.24
@schematics/update 0.803.24
rxjs 6.5.4
typescript 3.4.5
webpack 4.41.5
我没有尝试使用--force选项。还有另一种方法吗?
答案 0 :(得分:9)
看起来像您浏览了其中一个错误:
Package "@ngtools/webpack" has an incompatible peer dependency to "typescript" (requires ">=3.4 < 3.6", would install "3.7.5").
尝试使用与TypeScript 3.4至3.5兼容的@ ngtools / webpack较低版本。
或者,将package.json中的TypeScript版本更新为3.7.5并运行npm update
,那么您应该能够更新@ angular / core和@ angular / cli。
答案 1 :(得分:4)
ng update @angular/core @angular/cli --force
可能需要带有 --force
标志,请参阅 original answer of an Angular core member。
答案 2 :(得分:3)
就我而言,解决方法是在运行 ng update [package] 时使用 --force
标志来覆盖依赖关系问题。
无论如何这都会升级包,您可以使用更新的依赖项验证您的应用。如果该第三方依赖项仍因重大更改而需要更新,则需要更新该包。
答案 3 :(得分:0)
就我而言,接受的答案不起作用。所以我执行了以下命令,它对我有用。
npm install @angular/cli@latest @angular-devkit/build-angular@latest --save-dev
但我是在我的本地项目之一上这样做的,而不是系统上的全局角度版本。