大部分情况下的报错是因为网络不稳定的原因。
解决方法
1 删除项目文件夹里的node_module
2 清除一下npm的缓存,再重新安装依赖
npm cache clean --force
npm install
但是
我遇到的报错信息
npm ERR! code 1
npm ERR! path F:\baiduwangpan\reba2\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@14.15.0 | win32 | x64
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack at PythonFinder.failNoPython (F:\baiduwangpan\reba2\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (F:\baiduwangpan\reba2\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack at callback (F:\baiduwangpan\reba2\node_modules\graceful-fs\polyfills.js:299:20)
npm ERR! gyp ERR! stack at FSReqCallback.oncomplete (fs.js:183:21)
npm ERR! gyp ERR! System Windows_NT 10.0.18363
npm ERR! gyp ERR! command "D:\\软件\\Nodejs\\nodejs\\node.exe" "F:\\baiduwangpan\\reba2\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd F:\baiduwangpan\reba2\node_modules\node-sass
npm ERR! gyp ERR! node -v v14.15.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\baibai\AppData\Local\npm-cache\_logs\2021-06-11T06_13_21_914Z-debug.log
5-npminsatll报错.png
解决方法
1 去C:\Users\baibai 删除 .npmrc文件
2 删除项目文件夹里的node_module
3 执行命令
npm cache clean --force
npm install
成功截图
7-完成.png
奇奇怪怪,记录完毕。
https://blog.csdn.net/zsl15039718107/article/details/104128166