由于 node-gyp,无法安装节点模块

Fail to install node modules because of node-gyp

我正在尝试“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.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 版本,但没有任何改变 我尝试安装当前版本,但遇到了与以前相同的问题。

提前致谢

您应该将 python2.7 安装到您的 os

好的,问题已通过以下 2 个命令解决

npm config set msvs_version 2015 –global

npm config set python python2.7