gyp 报错 not found:python2

在使用vue-cli创建vue3项目时,安装依赖时,报错

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 (D:\studyVue\cli-vue3\cli-vue3\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\studyVue\cli-vue3\cli-vue3\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\studyVue\cli-vue3\cli-vue3\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\studyVue\cli-vue3\cli-vue3\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\studyVue\cli-vue3\cli-vue3\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\studyVue\cli-vue3\cli-vue3\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\studyVue\cli-vue3\cli-vue3\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\studyVue\cli-vue3\cli-vue3\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\studyVue\cli-vue3\cli-vue3\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\studyVue\cli-vue3\cli-vue3\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\studyVue\cli-vue3\cli-vue3\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\studyVue\cli-vue3\cli-vue3\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198: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:\Users\Chafferer\.windows-build-tools\python27\python.EXE
npm ERR! gyp verb check python version `C:\Users\Chafferer\.windows-build-tools\python27\python.EXE -c "import sys; print "2.7.15

1、先安装gyp : npm install -g node-gyp;
2、检查python的版本号,我这里使用的是2.7版本,配置环境变量,并且设置npm的变量:npm config set python python2.7
3、执行 npm config set msvs_version 2017;最后重新npm install 即可;

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐