重新拉去代码npm install 失败

今天在npm install 的时候报依赖错误

 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: [email protected]
npm ERR! Found: [email protected]
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 [email protected]
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 都不能解决这个问题,后来比较了新旧电脑的两个项目,原来是新缺少了package-lock.json这个文件。

package-lock.json这个文件的作用是锁定依赖版本号,具体到特定的版本,例如

 "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只能描述大版本号,因此在添加完package-lock.json文件之后,在此执行npm install 后成功安装了依赖

你可能感兴趣的:(重新拉去代码npm install 失败)