gyp 动词 'which' 失败 错误: 未找到: python2 for yarn add node-sass 命令



我正在处理一个项目,需要将 Sass 加载器添加到我的项目依赖项中,该依赖项需要节点 sass 才能工作。 我安装了 SASS 加载器

yarn add sass-loader@6.0.6

而且效果很好。但是当我尝试使用这个安装节点时:

yarn add node-sass@4.5.3
warning " > react-modal@2.2.2" has incorrect peer dependency "react-dom@^0.14.0 || ^15.0.0".
[4/4] Building fresh packages...
[-/3] ⢀ waiting...
[-/3] ⠠ waiting...
error C:UsersITDesktopreact-course-projectsindecision-appnode_modulesnode-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:UsersITDesktopreact-course-projectsindecision-appnode_modulesnode-sass
Output:
Building: C:Program Filesnodejsnode.exe C:UsersITDesktopreact-course-projectsindecision-appnode_modulesnode-gypbinnode-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using node-gyp@3.8.0
gyp info using node@10.16.3 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure [],
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (C:UsersITDesktopreact-course-projectsindecision-appnode_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed   stack:
gyp verb `which` failed    'Error: not found: pythonn    at getNotFoundError 
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:Python27python.exe
gyp verb check python version `C:Python27python.exe -c "import sys; print "2.7.0
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 10.16.3
gyp info spawn C:Python27python.exe
gyp info spawn args [ 'C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-gyp\gyp\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=auto',
gyp info spawn args   '-I',
gyp info spawn args   '-Dmodule_root_dir=C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-sass',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-sass\build',
gyp info spawn args   '-Goutput_dir=.' ]
Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir C:UsersIT.node-gyp10.16.3
gyp verb found first Solution file build/binding.sln
gyp verb could not find "msbuild.exe" in PATH - finding location in registry
gyp ERR! build error
gyp ERR! stack Error: Command failed: reg query "HKLMSoftwareMicrosoftMSBuildToolsVersions" /s /reg:32
gyp ERR! stack 'reg' is not recognized as an internal or external command,
gyp ERR! stack operable program or batch file.
gyp ERR! stack
gyp ERR! stack Can't find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?gyp ERR! stack     at C:UsersITDesktopreact-course-projectsindecision-appnode_modulesnode-gyplibbuild.js:142:25
"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:UsersITDesktopreact-course-projectsindecision-appnode_modulesnode-sass
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok`enter code here`

我尝试删除节点模块并重新安装它,但我不起作用 节点 -v 10.16.0 npm -v 6.9.0

看起来 sass-loader@6.0.6 使用了节点不支持的较旧的节点依赖关系。我会尝试使用 sass-loader@latest 看看它是否至少使用 node-sass 4.9 来支持节点 10 https://github.com/sass/node-sass#supported-nodejs-versions-vary-by-release-please-consult-the-releases-page-below-is-a-quick-guide-for-minimum-support

最新更新