今天在npm install 的時(shí)候報(bào)依賴(lài)錯(cuò)誤
D:\project\dhhs_erp_web>npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: ele-admin-pro-template@1.5.0
npm ERR! Found: vue@3.1.5
npm ERR! node_modules/vue
npm ERR! vue@"~3.1.5" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.2.0" from vue-router@4.0.14
npm ERR! node_modules/vue-router
npm ERR! vue-router@"~4.0.10" 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\dell\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\dell\AppData\Local\npm-cache\_logs\2022-03-29T03_26_51_523Z-debug.log
不管是重新拉去代碼户辞,還是重新install 都不能解決這個(gè)問(wèn)題武通,后來(lái)比較了新舊電腦的兩個(gè)項(xiàng)目渴频,原來(lái)是新缺少了package-lock.json這個(gè)文件桑驱。
package-lock.json這個(gè)文件的作用是鎖定依賴(lài)版本號(hào)懂盐,具體到特定的版本逸嘀,例如
"node_modules/@amap/amap-jsapi-loader": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@amap/amap-jsapi-loader/-/amap-jsapi-loader-1.0.1.tgz",
"integrity": "sha512-nPyLKt7Ow/ThHLkSvn2etQlUzqxmTVgK7bIgwdBRTg2HK5668oN7xVxkaiRe3YZEzGzfV2XgH5Jmu2T73ljejw=="
},
"node_modules/@ant-design/colors": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@ant-design/colors/-/colors-5.1.1.tgz",
"integrity": "sha512-Txy4KpHrp3q4XZdfgOBqLl+lkQIc3tEvHXOimRN1giX1AEC7mGtyrO9p8iRGJ3FLuVMGa2gNEzQyghVymLttKQ==",
"dependencies": {
"@ctrl/tinycolor": "^3.3.1"
}
},
"node_modules/@ant-design/icons-svg": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@ant-design/icons-svg/-/icons-svg-4.1.0.tgz",
"integrity": "sha512-Fi03PfuUqRs76aI3UWYpP864lkrfPo0hluwGqh7NJdLhvH4iRDc3jbJqZIvRDLHKbXrvAfPPV3+zjUccfFvWOQ=="
},
而package.json只能描述大版本號(hào),因此在添加完package-lock.json文件之后允粤,在此執(zhí)行npm install 后成功安裝了依賴(lài)