如何修复:gyp ERR!堆栈错误:找不到Python可执行文件“ python”

时间:2019-08-29 06:39:18

标签: yarnpkg node-gyp node-sass

我已删除节点模块并重新安装它,但未解决问题。如果我运行yarn add node-sass,则终端中会出现以下错误

gyp verb `which` failed     at C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed   stack:
gyp verb `which` failed    'Error: not found: python\n    at getNotFoundError (C:\\Users\\IT\\Desktop\\react-course-projects\\indecision-app\\node_modules\\which\\which.js:13:12)\n    at F (C:\\Users\\IT\\Desktop\\react-course-projects\\indecision-app\\node_modules\\which\\which.js:68:19)\n    at E (C:\\Users\\IT\\Desktop\\react-course-projects\\indecision-app\\node_modules\\which\\which.js:80:29)\n    at C:\\Users\\IT\\Desktop\\react-course-projects\\indecision-app\\node_modules\\which\\which.js:89:16\n    at C:\\Users\\IT\\Desktop\\react-course-projects\\indecision-app\\node_modules\\isexe\\index.js:42:5\n    at C:\\Users\\IT\\Desktop\\react-course-projects\\indecision-app\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:153:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at callback (C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\graceful-fs\polyfills.js:295:20)
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:153:21)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\IT\\Desktop\\react-course-projects\\indecision-app\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-sass
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

节点和npm版本是

node- v 10.16.0
npm -v 6.9.0

2 个答案:

答案 0 :(得分:0)

执行以下步骤:

npm install -g node-gyp

npm install --global --production windows-build-tools

答案 1 :(得分:0)

这是我从运行您给我的最后一条命令时得到的新错误

Error: spawnSync powershell.exe ENOENT
    at Object.spawnSync (internal/child_process.js:1002:20)
    at Object.spawnSync (child_process.js:614:24)
    at spawnSync (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:67:36)
    at Object.queryRegFromPowershell (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:73:3)
    at loop (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:113:16)
    at opts.shift (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:116:7)
    at spawn (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:100:5)
    at spawnSync (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:68:2)
    at Object.queryRegFromRegExe (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:96:3)
    at loop (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:113:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! windows-build-tools@4.0.0 postinstall: `node ./dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the windows-build-tools@4.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.