【问题标题】:How to fix: gyp ERR! stack Error: Can't find Python executable "python"'如何修复:gyp ERR!堆栈错误:找不到 Python 可执行文件“python”'
【发布时间】:2020-01-02 09:17:54
【问题描述】:

我已删除节点模块并重新安装它,但没有解决问题。如果我运行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.

node 和 npm 版本是

node- v 10.16.0
npm -v 6.9.0

【问题讨论】:

    标签: yarnpkg node-gyp node-sass


    【解决方案1】:

    这是我运行你给我的最后一个命令时遇到的新错误

    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.
    

    【讨论】:

      【解决方案2】:

      按照步骤:

      npm install -g node-gyp
      
      npm install --global --production windows-build-tools
      

      【讨论】:

      • 第一个命令运行成功,但第二个给出了这个错误:npm ERR! windows-build-tools@5.2.2 安装后脚本失败。然后我再次运行 yarn add node-sass 但仍然得到我上面发布的相同错误。
      • 你能用吗:npm install --global --production windows-build-tools@4.0.0。在 cmd 管理员模式下运行。
      • 我使用了它,它还引发了我在下面提供的另一个错误
      猜你喜欢
      • 2018-05-07
      • 2019-11-04
      • 2019-09-18
      • 2017-07-03
      • 2021-06-26
      • 1970-01-01
      • 2019-12-01
      • 2014-06-27
      • 2020-06-26
      相关资源
      最近更新 更多