npm安装包出现Invalid Version,npm list报错UNMET DEPENDENCY报错

执行 npm install 出现报错

2097 verbose stack TypeError: Invalid Version:
2097 verbose stack     at new SemVer (D:\Program Files\nodejs\node_modules\npm\node_modules\semver\classes\semver.js:38:13)
2097 verbose stack     at compare (D:\Program Files\nodejs\node_modules\npm\node_modules\semver\functions\compare.js:3:32)
2097 verbose stack     at Object.gte (D:\Program Files\nodejs\node_modules\npm\node_modules\semver\functions\gte.js:2:30)
2097 verbose stack     at Node.canDedupe (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\node.js:1035:32)
2097 verbose stack     at PlaceDep.pruneDedupable (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:463:14)
2097 verbose stack     at PlaceDep.placeInTree (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:325:14)
2097 verbose stack     at PlaceDep.place (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:214:10)
2097 verbose stack     at new PlaceDep (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:71:10)
2097 verbose stack     at D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:944:31
2097 verbose stack     at Array.map (<anonymous>)
2098 verbose cwd E:\Projects\luaProjects\apisix-dashboard-master\web
2099 verbose Windows_NT 10.0.17763
2100 verbose argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@umijs/plugin-blocks" "--legacy-peer-deps"
2101 verbose node v16.12.0
2102 verbose npm  v8.1.0
2103 error Invalid Version:
2104 verbose exit 1

粗略看起来像是npm的问题 ,执行 npm list 试试

执行 npm list 出现报错:

+-- UNMET DEPENDENCY @umijs/plugin-blocks@^2.0.5
+-- UNMET DEPENDENCY @umijs/plugin-esbuild@^1.0.0-beta.2
+-- UNMET DEPENDENCY @umijs/preset-ant-design-pro@^1.2.0
+-- UNMET DEPENDENCY @umijs/preset-react@^1.7.11
+-- UNMET DEPENDENCY @umijs/preset-ui@^2.1.11
...
+-- UNMET DEPENDENCY umi@^3.1.2
...
npm ERR! code ELSPROBLEMS
npm ERR! missing: @umijs/plugin-blocks@^2.0.5, required by apisix-dashboard@2.13.0
npm ERR! missing: @umijs/plugin-esbuild@^1.0.0-beta.2, required by apisix-dashboard@2.13.0
npm ERR! missing: @umijs/preset-ant-design-pro@^1.2.0, required by apisix-dashboard@2.13.0
npm ERR! missing: @umijs/preset-react@^1.7.11, required by apisix-dashboard@2.13.0
npm ERR! missing: @umijs/preset-ui@^2.1.11, required by apisix-dashboard@2.13.0
npm ERR! missing: umi-request@^1.0.8, required by apisix-dashboard@2.13.0
npm ERR! missing: umi@^3.1.2, required by apisix-dashboard@2.13.0

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxxxxxxxx\AppData\Local\npm-cache\_logs\2022-07-28T11_52_41_706Z-debug.log

 

出现这个内容应该是包损坏,导致npm无法正常解析。

解决方法是,先卸载,再重新安装

npm uninstall -g @umijs/plugin-blocks  @umijs/plugin-esbuild  @umijs/preset-ant-design-pro   @umijs/preset-react @umijs/preset-ui umi umi-request 

 

最后 再重新安装就安装正常了

npm install -g  @umijs/plugin-blocks  @umijs/plugin-esbuild  @umijs/preset-ant-design-pro   @umijs/preset-react @umijs/preset-ui umi umi-request 

 

posted @ 2022-07-28 20:09  醒日是归时  阅读(9155)  评论(0编辑  收藏  举报