NCU(npm-check-update)更新角度包失败
Posted
技术标签:
【中文标题】NCU(npm-check-update)更新角度包失败【英文标题】:NCU (npm-check-update) updating angular packages fails 【发布时间】:2021-10-29 00:38:56 【问题描述】:所以尝试更新到今天的所有内容,我使用了以下命令:
G:\Projects\salarkazazi> npm i -g npm-check-updates
这是输出:
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain
circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
changed 313 packages, and audited 314 packages in 41s
28 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
然后:
PS G:\Projects\salarkazazi> ncu -u
它显示了 2 个主要更新和 typescript 次要版本更新:
Upgrading G:\Projects\salarkazazi\package.json
[====================] 25/25 100%
@angular-devkit/build-angular ~12.2.2 → ~12.2.3
@angular/cli ~12.2.2 → ~12.2.3
@angular/compiler-cli ~12.2.0 → ~12.2.3
@types/jasmine ~3.8.0 → ~3.8.2
@types/node ^12.11.1 → ^16.7.6
jasmine-core ~3.8.0 → ~3.9.0
karma ~6.3.0 → ~6.3.4
typescript ~4.3.5 → ~4.4.2
@angular/animations ~12.2.0 → ~12.2.3
@angular/common ~12.2.0 → ~12.2.3
@angular/compiler ~12.2.0 → ~12.2.3
@angular/core ~12.2.0 → ~12.2.3
@angular/forms ~12.2.0 → ~12.2.3
@angular/platform-browser ~12.2.0 → ~12.2.3
@angular/platform-browser-dynamic ~12.2.0 → ~12.2.3
@angular/router ~12.2.0 → ~12.2.3
rxjs ~6.6.0 → ~7.3.0
tslib ^2.3.0 → ^2.3.1
Run npm install to install new versions.
所以当我尝试安装更新时,我收到以下错误:
PS G:\Projects\salarkazazi> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: salarkazazi@0.0.0
npm ERR! Found: typescript@4.4.2
npm ERR! node_modules/typescript
npm ERR! dev typescript@"~4.4.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@">=4.2.3 <4.4" from @angular/compiler-cli@12.2.3
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"~12.2.3" from the root project
npm ERR! peer @angular/compiler-cli@"^12.0.0" from @angular-devkit/build-angular@12.2.3
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~12.2.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Salar\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Salar\AppData\Local\npm-cache\_logs\2021-08-30T08_03_27_428Z-debug.log
这是日志文件:
0 verbose cli [
0 verbose cli 'G:\\Program Files\\nodejs\\node.exe',
0 verbose cli 'C:\\Users\\Salar\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli 'install'
0 verbose cli ]
1 info using npm@7.21.0
2 info using node@v14.17.5
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:C:\Users\Salar\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 11ms
6 timing config:load:builtin Completed in 11ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:G:\Projects\salarkazazi\.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:C:\Users\Salar\.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:C:\Users\Salar\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 19ms
19 timing npm:load:configload Completed in 19ms
20 timing npm:load:setTitle Completed in 0ms
21 timing npm:load:setupLog Completed in 0ms
22 timing config:load:flatten Completed in 3ms
23 timing npm:load:cleanupLog Completed in 3ms
24 timing npm:load:configScope Completed in 0ms
25 timing npm:load:projectScope Completed in 2ms
26 timing npm:load Completed in 29ms
27 timing arborist:ctor Completed in 1ms
28 timing idealTree:init Completed in 948ms
29 timing idealTree:userRequests Completed in 1ms
30 silly idealTree buildDeps
31 silly fetch manifest @angular/animations@~12.2.3
32 http fetch GET 200 https://registry.npmjs.org/@angular%2fanimations 1255ms (cache revalidated)
33 silly fetch manifest @angular/core@~12.2.3
34 http fetch GET 200 https://registry.npmjs.org/@angular%2fcore 161ms (cache revalidated)
35 silly fetch manifest rxjs@~7.3.0
36 http fetch GET 200 https://registry.npmjs.org/rxjs 161ms (cache revalidated)
37 silly fetch manifest zone.js@~0.11.4
38 http fetch GET 200 https://registry.npmjs.org/zone.js 164ms (cache revalidated)
39 silly fetch manifest @angular/common@~12.2.3
40 http fetch GET 200 https://registry.npmjs.org/@angular%2fcommon 202ms (cache revalidated)
41 silly fetch manifest @angular/compiler@~12.2.3
42 http fetch GET 200 https://registry.npmjs.org/@angular%2fcompiler 474ms (cache revalidated)
43 silly fetch manifest @angular/forms@~12.2.3
44 http fetch GET 200 https://registry.npmjs.org/@angular%2fforms 306ms (cache revalidated)
45 silly fetch manifest @angular/platform-browser@~12.2.3
46 http fetch GET 200 https://registry.npmjs.org/@angular%2fplatform-browser 175ms (cache revalidated)
47 silly fetch manifest @angular/platform-browser-dynamic@~12.2.3
48 http fetch GET 200 https://registry.npmjs.org/@angular%2fplatform-browser-dynamic 176ms (cache revalidated)
49 silly fetch manifest @angular/router@~12.2.3
50 http fetch GET 200 https://registry.npmjs.org/@angular%2frouter 165ms (cache revalidated)
51 silly fetch manifest @angular-devkit/build-angular@~12.2.3
52 http fetch GET 200 https://registry.npmjs.org/@angular-devkit%2fbuild-angular 165ms (cache revalidated)
53 silly fetch manifest @angular/compiler-cli@~12.2.3
54 http fetch GET 200 https://registry.npmjs.org/@angular%2fcompiler-cli 182ms (cache revalidated)
55 silly fetch manifest typescript@~4.4.2
56 http fetch GET 200 https://registry.npmjs.org/typescript 6818ms (cache updated)
57 silly fetch manifest typescript@>=4.2.3 <4.4
58 timing idealTree Completed in 11485ms
59 timing command:install Completed in 11507ms
60 verbose stack Error: unable to resolve dependency tree
60 verbose stack at Arborist.[failPeerConflict] (C:\Users\Salar\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1274:25)
60 verbose stack at Arborist.[loadPeerSet] (C:\Users\Salar\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1241:34)
60 verbose stack at async Arborist.[loadPeerSet] (C:\Users\Salar\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1226:23)
60 verbose stack at async Arborist.[buildDepStep] (C:\Users\Salar\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:877:11)
60 verbose stack at async Arborist.buildIdealTree (C:\Users\Salar\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:206:7)
60 verbose stack at async Promise.all (index 1)
60 verbose stack at async Arborist.reify (C:\Users\Salar\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:147:5)
60 verbose stack at async Install.install (C:\Users\Salar\AppData\Roaming\npm\node_modules\npm\lib\install.js:150:5)
61 verbose cwd G:\Projects\salarkazazi
62 verbose Windows_NT 10.0.19042
63 verbose argv "G:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Salar\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
64 verbose node v14.17.5
65 verbose npm v7.21.0
66 error code ERESOLVE
67 error ERESOLVE unable to resolve dependency tree
68 error
69 error While resolving: [1msalarkazazi[22m@[1m0.0.0[22m
69 error Found: [1mtypescript[22m@[1m4.4.2[22m[2m[22m
69 error [2mnode_modules/typescript[22m
69 error [33mdev[39m [1mtypescript[22m@"[1m~4.4.2[22m" from the root project
69 error
69 error Could not resolve dependency:
69 error [35mpeer[39m [1mtypescript[22m@"[1m>=4.2.3 <4.4[22m" from [1m@angular/compiler-cli[22m@[1m12.2.3[22m[2m[22m
69 error [2mnode_modules/@angular/compiler-cli[22m
69 error [33mdev[39m [1m@angular/compiler-cli[22m@"[1m~12.2.3[22m" from the root project
69 error [35mpeer[39m [1m@angular/compiler-cli[22m@"[1m^12.0.0[22m" from [1m@angular-devkit/build-angular[22m@[1m12.2.3[22m[2m[22m
69 error [2mnode_modules/@angular-devkit/build-angular[22m
69 error [33mdev[39m [1m@angular-devkit/build-angular[22m@"[1m~12.2.3[22m" from the root project
69 error
69 error Fix the upstream dependency conflict, or retry
69 error this command with --force, or --legacy-peer-deps
69 error to accept an incorrect (and potentially broken) dependency resolution.
69 error
69 error See C:\Users\Salar\AppData\Local\npm-cache\eresolve-report.txt for a full report.
70 verbose exit 1
我猜对了,主要与 Typescript 相关的依赖树存在某种问题吗?
在我的 package-lock.json 中,我有这个 typescript 在对等依赖项中,它对我大喊的版本是一个错误:
"node_modules/@angular/compiler-cli":
"version": "12.2.2",
"resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-12.2.2.tgz",
"integrity": "sha512-n4X7nE7NEJm8QfKUkPgTXBqyF66FnLtFhjsTnqqSi9u1CdqpBLY7mJkWvQuYob4QfRoKoi2+UxNhoi26fvngCw==",
"dev": true,
"dependencies":
"@babel/core": "^7.8.6",
"@babel/types": "^7.8.6",
"canonical-path": "1.0.0",
"chokidar": "^3.0.0",
"convert-source-map": "^1.5.1",
"dependency-graph": "^0.11.0",
"magic-string": "^0.25.0",
"minimist": "^1.2.0",
"reflect-metadata": "^0.1.2",
"semver": "^7.0.0",
"source-map": "^0.6.1",
"sourcemap-codec": "^1.4.8",
"tslib": "^2.2.0",
"yargs": "^17.0.0"
,
"bin":
"ivy-ngcc": "ngcc/main-ivy-ngcc.js",
"ng-xi18n": "src/extract_i18n.js",
"ngc": "src/main.js",
"ngcc": "ngcc/main-ngcc.js"
,
"engines":
"node": "^12.14.1 || >=14.0.0"
,
"peerDependencies":
"@angular/compiler": "12.2.2",
"typescript": ">=4.2.3 <4.4"
,
"node_modules/@angular-devkit/build-angular":
"version": "12.2.2",
"resolved": "https://registry.npmjs.org/@angular-devkit/build-angular/-/build-angular-12.2.2.tgz",
"integrity": "sha512-/KBz8YlujmRZwWqk3fjV5S4IWKEfDE6Vhpr2uo1GC6KtdK7/tA9usvm3ZGAFMu3DXn3eJwe2StgUnegPg3gqxA==",
"dev": true,
"dependencies":
"@ampproject/remapping": "1.0.1",
"@angular-devkit/architect": "0.1202.2",
"@angular-devkit/build-optimizer": "0.1202.2",
"@angular-devkit/build-webpack": "0.1202.2",
"@angular-devkit/core": "12.2.2",
"@babel/core": "7.14.8",
"@babel/generator": "7.14.8",
"@babel/helper-annotate-as-pure": "7.14.5",
"@babel/plugin-proposal-async-generator-functions": "7.14.7",
"@babel/plugin-transform-async-to-generator": "7.14.5",
"@babel/plugin-transform-runtime": "7.14.5",
"@babel/preset-env": "7.14.8",
"@babel/runtime": "7.14.8",
"@babel/template": "7.14.5",
"@discoveryjs/json-ext": "0.5.3",
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
"@ngtools/webpack": "12.2.2",
"ansi-colors": "4.1.1",
"babel-loader": "8.2.2",
"browserslist": "^4.9.1",
"cacache": "15.2.0",
"caniuse-lite": "^1.0.30001032",
"circular-dependency-plugin": "5.2.2",
"copy-webpack-plugin": "9.0.1",
"core-js": "3.16.0",
"critters": "0.0.10",
"css-loader": "6.2.0",
"css-minimizer-webpack-plugin": "3.0.2",
"esbuild": "0.12.17",
"find-cache-dir": "3.3.1",
"glob": "7.1.7",
"https-proxy-agent": "5.0.0",
"inquirer": "8.1.2",
"karma-source-map-support": "1.4.0",
"less": "4.1.1",
"less-loader": "10.0.1",
"license-webpack-plugin": "2.3.20",
"loader-utils": "2.0.0",
"mini-css-extract-plugin": "2.1.0",
"minimatch": "3.0.4",
"open": "8.2.1",
"ora": "5.4.1",
"parse5-html-rewriting-stream": "6.0.1",
"piscina": "3.1.0",
"postcss": "8.3.6",
"postcss-import": "14.0.2",
"postcss-loader": "6.1.1",
"postcss-preset-env": "6.7.0",
"regenerator-runtime": "0.13.9",
"resolve-url-loader": "4.0.0",
"rxjs": "6.6.7",
"sass": "1.36.0",
"sass-loader": "12.1.0",
"semver": "7.3.5",
"source-map-loader": "3.0.0",
"source-map-support": "0.5.19",
"style-loader": "3.2.1",
"stylus": "0.54.8",
"stylus-loader": "6.1.0",
"terser": "5.7.1",
"terser-webpack-plugin": "5.1.4",
"text-table": "0.2.0",
"tree-kill": "1.2.2",
"tslib": "2.3.0",
"webpack": "5.50.0",
"webpack-dev-middleware": "5.0.0",
"webpack-dev-server": "3.11.2",
"webpack-merge": "5.8.0",
"webpack-subresource-integrity": "1.5.2"
,
"engines":
"node": "^12.14.1 || >=14.0.0",
"npm": "^6.11.0 || ^7.5.6",
"yarn": ">= 1.13.0"
,
"peerDependencies":
"@angular/compiler-cli": "^12.0.0",
"@angular/localize": "^12.0.0",
"@angular/service-worker": "^12.0.0",
"karma": "^6.3.0",
"ng-packagr": "^12.0.0",
"protractor": "^7.0.0",
"tailwindcss": "^2.0.0",
"tslint": "^6.1.0",
"typescript": "~4.2.3 || ~4.3.2"
,
"peerDependenciesMeta":
"@angular/localize":
"optional": true
,
"@angular/service-worker":
"optional": true
,
"karma":
"optional": true
,
"ng-packagr":
"optional": true
,
"protractor":
"optional": true
,
"tailwindcss":
"optional": true
,
"tslint":
"optional": true
,
我该如何解决这个问题?
【问题讨论】:
【参考方案1】:重启
ng update @angular/core@12 @angular/cli@12
更新到最新的 12.x 版本
npm outdated
通过键入ng update [specific dependency]@[wanted version]
将您的依赖项一一升级到npm outdated
中提到的所需版本,提交这些更改
【讨论】:
以上是关于NCU(npm-check-update)更新角度包失败的主要内容,如果未能解决你的问题,请参考以下文章