npm install报错command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
执行npm install 报错信息
12月10日 20:27
npm ERR! code 1
npm ERR! path C:\wamp64\www\kyy2.0\xgwx2\node_modules\images
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@16.13.1 | 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 (C:\wamp64\www\kyy2.0\xgwx2\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (C:\wamp64\www\kyy2.0\xgwx2\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack at callback (C:\wamp64\www\kyy2.0\xgwx2\node_modules\graceful-fs\polyfills.js:299:20)
npm ERR! gyp ERR! stack at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\wamp64\\www\\kyy2.0\\xgwx2\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\wamp64\www\kyy2.0\xgwx2\node_modules\images
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
报错原因是本地缺少python环境
首先执行npm install -g node-gyp 全局安装node-gyp
执行node-gyp list,若提示需要node-gyp install, 再次执行node-gyp install
执行 npm install --global --production windows-build-tools安装python环境
*如果执行失败可能是由于npm版本过高,降低npm版本到6(安装完以后可升回来)或使用cnpm进行安装
安装成功提示后,注意安装的python信息(有可能是python2.7的子版本,需要注意)
安装成功后,需要执行一下两步
1. 环境变量设置
在Path行添加安装路径 eg:C:\Users\.windows-build-tools\python27
2.cmd设置npm config set python python2.7.15(我的是2.7.15,要设置完整版本号才行)
此时cmd中执行python,会显示python信息
eg:
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
这样就是python已安装成功
下面正常重新执行npm install就行
原文链接:https://blog.csdn.net/weixin_43355831/article/details/121923634
12月10日 20:27
npm ERR! code 1
npm ERR! path C:\wamp64\www\kyy2.0\xgwx2\node_modules\images
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@16.13.1 | 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 (C:\wamp64\www\kyy2.0\xgwx2\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (C:\wamp64\www\kyy2.0\xgwx2\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack at callback (C:\wamp64\www\kyy2.0\xgwx2\node_modules\graceful-fs\polyfills.js:299:20)
npm ERR! gyp ERR! stack at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\wamp64\\www\\kyy2.0\\xgwx2\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\wamp64\www\kyy2.0\xgwx2\node_modules\images
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
报错原因是本地缺少python环境
首先执行npm install -g node-gyp 全局安装node-gyp
执行node-gyp list,若提示需要node-gyp install, 再次执行node-gyp install
执行 npm install --global --production windows-build-tools安装python环境
*如果执行失败可能是由于npm版本过高,降低npm版本到6(安装完以后可升回来)或使用cnpm进行安装
安装成功提示后,注意安装的python信息(有可能是python2.7的子版本,需要注意)
安装成功后,需要执行一下两步
1. 环境变量设置
在Path行添加安装路径 eg:C:\Users\.windows-build-tools\python27
2.cmd设置npm config set python python2.7.15(我的是2.7.15,要设置完整版本号才行)
此时cmd中执行python,会显示python信息
eg:
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
这样就是python已安装成功
下面正常重新执行npm install就行
原文链接:https://blog.csdn.net/weixin_43355831/article/details/121923634