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

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐