npm install安装依赖遇到的各种问题
npm install安装依赖遇到的各种问题
今天npm install想要给项目安装依赖,报错如下:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: creditmis-web-v2@3.0.0
npm ERR! Found: vue@2.6.10
npm ERR! node_modules/vue
npm ERR! vue@"2.6.10" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.6.14" from @wangeditor/editor-for-vue@1.0.2
npm ERR! node_modules/@wangeditor/editor-for-vue
npm ERR! @wangeditor/editor-for-vue@"^1.0.2" 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 install --legacy-peer-deps即可解决冲突,
但是我解决了这个冲突后,又遇到了类似下面的错误:
PS C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2> npm install --legacy-peer-deps
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/@ant-design/colors/download/@ant-design/colors-3.2.2.tgz failed, reason: certificate has expired什么意思
这是旧淘宝镜像源https://registry.npm.taobao.org/已经过期,应该使用新淘宝镜像源npm config set registry https://registry.npmmirror.com,设置为新源后,又出现的类似下面的问题
npm ERR! code 1
npm ERR! path C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\nvm4w\nodejs\node.exe C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli 'C:\\nvm4w\\nodejs\\node.exe',
npm ERR! gyp verb cli 'C:\\Users\\lenovo\\Desktop\\LDSKProjects\\creditmis-web-v2\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.20.2 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed at F (C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed at E (C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed at C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed at C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed at C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:202:21)
npm ERR! gyp verb `which` failed python2 Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed at F (C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed at E (C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed at C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed at C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed at C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:202:21) {
npm ERR! gyp verb `which` failed code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\Python311\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Python311\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack File "<string>", line 1
npm ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:402:12)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm ERR! gyp ERR! System Windows_NT 10.0.26100
npm ERR! gyp ERR! command "C:\\nvm4w\\nodejs\\node.exe" "C:\\Users\\lenovo\\Desktop\\LDSKProjects\\creditmis-web-v2\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.20.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
这是因为Python版本过高,且node版本过高.顺利下载了python 2.7.18,在下载node 14.21.3的时候又出现了问题:
下面两个报错总是会出现:
PS C:\Users\lenovo\Desktop\LDSKProjects\creditmis-web-v2> nvm install 14.21.3
Downloading node.js version 14.21.3 (64-bit)...
Complete
Downloading npm...
Creating C:\Users\lenovo\AppData\Local\Temp\nvm-install-1899493804\temp
Downloading npm version 6.14.18... Complete
Installing npm v6.14.18...
error installing 14.21.3: open C:\Users\lenovo\AppData\Local\Temp\nvm-npm-1906736772\npm-v6.14.18.zip: The system cannot find the file specified.
和类似于:
The process cannot access the file because it is being used by another process
荒废好几个小时,左试右试,终于发现应该是nvm版本过高,我的版本是1.2.2,在nvm文件夹中用卸载程序卸载并且安装1.1.12,并且注意nvm别安到C盘,别忘了配置环境变量,这时再下载一次node: nvm install 14.21.3,还是下不得,说是github没有回应,试用科学上网,无果,切换成镜像源:
nvm node_mirror https://nodejs.org/dist/
nvm npm_mirror https://registry.npmjs.org/npm/-/
清理缓存:
nvm cache clear
再下一次:
nvm install 14.21.3
终于成功,这个时候使用npm install --legacy-peer-deps终于成功下载了项目依赖,真是血泪篇章!
更多推荐
所有评论(0)