gyp动词“哪个”失败错误:找不到:python2 for yarn add node-sass命令

时间:2019-08-30 09:53:33

标签: yarnpkg node-gyp node-sass

我正在一个项目上,需要将sass loader添加到我的项目依赖项中,该依赖项需要节点sass才能工作。我用

安装了sass loader
yarn add sass-loader@6.0.6

,效果很好。但是,当我尝试使用此方法安装node-sass时:

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:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-sass
Output:
Building: 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 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:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\which\which.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: python\n    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:\Python27\python.exe
gyp verb check python version `C:\Python27\python.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:\Python27\python.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:\Users\IT\.node-gyp\10.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 "HKLM\Software\Microsoft\MSBuild\ToolsVersions" /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:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-gyp\lib\build.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:\Users\IT\Desktop\react-course-projects\indecision-app\node_modules\node-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

1 个答案:

答案 0 :(得分:0)

像sass-loader@6.0.6一样,它使用了node-sass不支持的较旧的node-sass依赖关系。我会尝试使用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