安装的node.js是16.13.1,第一次打开项目,运行npm install报错。莫名其妙的问题,报错代码如下。
6242 error code 1
6243 error path C:\Users\Lenovo\Desktop\renren-fast-vue\node_modules\node-sass
6244 error command failed
6245 error command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
6246 error gyp info it worked if it ends with ok
6246 error gyp info using node-gyp@3.8.0
6246 error gyp info using node@16.13.1 | win32 | x64
6246 error gyp ERR! configure error
6246 error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
6246 error gyp ERR! stack at PythonFinder.failNoPython (C:\Users\Lenovo\Desktop\renren-fast-vue\node_modules\node-gyp\lib\configure.js:484:19)
6246 error gyp ERR! stack at PythonFinder.<anonymous> (C:\Users\Lenovo\Desktop\renren-fast-vue\node_modules\node-gyp\lib\configure.js:509:16)
6246 error gyp ERR! stack at callback (C:\Users\Lenovo\Desktop\renren-fast-vue\node_modules\graceful-fs\polyfills.js:299:20)
6246 error gyp ERR! stack at FSReqCallback.oncomplete (node:fs:198:21)
6246 error gyp ERR! System Windows_NT 10.0.19042
6246 error gyp ERR! command "D:\\javaStudy\\node\\install\\node.exe" "C:\\Users\\Lenovo\\Desktop\\renren-fast-vue\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
6246 error gyp ERR! cwd C:\Users\Lenovo\Desktop\renren-fast-vue\node_modules\node-sass
6246 error gyp ERR! node -v v16.13.1
6246 error gyp ERR! node-gyp -v v3.8.0
6246 error gyp ERR! not ok
我卸载了16.13.1版本,重新安装的9.4.0版本的node.js,再执行npm install,成功。我对比了下两个版本下这个路径下C:\Users\Lenovo\AppData\Roaming\npm-cache文件目录,16.13.1版本下没有C:\Users\Lenovo\AppData\Roaming\npm-cache\node-sass\4.13.1\win32-x64-59_binding.node,可能是少了这个win32-x64-59_binding.node文件原因导致报错。
看着是缺少python或者python 环境配置的问题,在cmd下敲个python有没有返回
npm install --global --production windows-build-tools