【问题标题】:Fail to install node modules because of node-gyp由于 node-gyp 无法安装节点模块
【发布时间】:2021-11-16 01:10:17
【问题描述】:

我正在尝试“npm install”,但由于以下错误,安装未完成..

npm ERR! code 1
npm ERR! path C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@15.14.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2.7" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2.7
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:193:21)
npm ERR! gyp verb `which` failed  python2.7 Error: not found: python2.7
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:193:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb could not find "python2.7". checking python launcher
npm ERR! gyp verb build type Release
npm ERR! gyp verb architecture x64
npm ERR! gyp verb node dev dir C:\Users\BASILIS\.node-gyp\15.14.0
npm ERR! gyp verb found first Solution file build/binding.sln
npm ERR! gyp verb could not find "msbuild.exe" in PATH - finding location in registry
npm ERR! gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\node-gyp\lib\build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:369:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\BASILIS\\Desktop\\kronos-webapp\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\node-sass
npm ERR! gyp ERR! node -v v15.14.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

我尝试先安装 node-gyp@3.8.0 的版本但没有改变任何东西 我尝试安装当前版本,但我遇到了和以前一样的问题。

提前致谢

【问题讨论】:

    标签: python reactjs npm npm-install node-gyp


    【解决方案1】:

    好的问题已通过以下 2 个命令修复

    npm config set msvs_version 2015 –global
    
    npm config set python python2.7
    

    【讨论】:

      【解决方案2】:

      你应该在你的操作系统上安装 python2.7

      【讨论】:

      • 已安装
      • npm 错误! gyp verb check python 检查 PATH npm ERR 中的 Python 可执行文件“python2.7”! gyp动词which失败错误:未找到:python2.7 npm ERR! gyp 动词 which 在 getNotFoundError 失败 (C:\Users\BASILIS\Desktop\kronos-webapp\node_modules\which\which.js:13:12) 说它在你的路径中找不到 python
      • 这个答案可以通过解释为什么推荐的操作会导致成功来改进。
      猜你喜欢
      • 2017-07-27
      • 2020-04-27
      • 1970-01-01
      • 2014-01-30
      • 2020-01-05
      • 1970-01-01
      • 2020-02-22
      • 1970-01-01
      • 2019-01-08
      相关资源
      最近更新 更多