安装node-sass出错

npm安装node-sass出错

今天想改一下halo的评论组件,拉下来准备运行,npm install时出现错误

错误报告

1. 未找到python路径

Building: C:\Program Files\nodejs\node.exe F:\halo-comment-sakura\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'F:\\halo-comment-sakura\\node_modules\\node-gyp\\bin\\node-gyp.js',
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.15.1 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (F:\halo-comment-sakura\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (F:\halo-comment-sakura\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (F:\halo-comment-sakura\node_modules\which\which.js:80:29)
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\which\which.js:89:16
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (F:\halo-comment-sakura\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (F:\halo-comment-sakura\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (F:\halo-comment-sakura\node_modules\which\which.js:80:29)
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\which\which.js:89:16
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed   stack:
gyp verb `which` failed    'Error: not found: python2\n    at getNotFoundError (F:\\halo-comment-sakura\\node_modules\\which\\which.js:13:12)\n    at F (F:\\halo-comment-sakura\\node_modules\\which\\which.js:68:19)\n    at E (F:\\halo-comment-sakura\\node_modules\\which\\which.js:80:29)\n    at F:\\halo-comment-sakura\\node_modules\\which\\which.js:89:16\n    at F:\\halo-comment-sakura\\node_modules\\isexe\\index.js:42:5\n    at F:\\halo-comment-sakura\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:154:21)',
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 (F:\halo-comment-sakura\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (F:\halo-comment-sakura\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (F:\halo-comment-sakura\node_modules\which\which.js:80:29)
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\which\which.js:89:16
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed  python { Error: not found: python
gyp verb `which` failed     at getNotFoundError (F:\halo-comment-sakura\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (F:\halo-comment-sakura\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (F:\halo-comment-sakura\node_modules\which\which.js:80:29)
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\which\which.js:89:16
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at F:\halo-comment-sakura\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed   stack:
gyp verb `which` failed    'Error: not found: python\n    at getNotFoundError (F:\\halo-comment-sakura\\node_modules\\which\\which.js:13:12)\n    at F (F:\\halo-comment-sakura\\node_modules\\which\\which.js:68:19)\n    at E (F:\\halo-comment-sakura\\node_modules\\which\\which.js:80:29)\n    at F:\\halo-comment-sakura\\node_modules\\which\\which.js:89:16\n    at F:\\halo-comment-sakura\\node_modules\\isexe\\index.js:42:5\n    at F:\\halo-comment-sakura\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:154: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 (F:\halo-comment-sakura\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (F:\halo-comment-sakura\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at callback (F:\halo-comment-sakura\node_modules\graceful-fs\polyfills.js:295:20)
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "F:\\halo-comment-sakura\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd F:\halo-comment-sakura\node_modules\node-sass
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

主要为

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

2. 未能加载 Visual C++ 组件“VCBuild.exe”

节点 1 上的项目“F:\halo-comment-sakura\node_modules\node-sass\build\binding.sln”(默认目标)。
ValidateSolutionConfiguration:
  正在生成解决方案配置“Release|x64”。
MSBUILD : error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装 .NET Framework 2.0 SDK;2) 安装 Microsoft Visual Stu
dio 2005;或 3) 如果将该组件安装到了其他位置,请将其位置添加到系统路径中。 [F:\halo-comment-sakura\node_modules\node-sass\build\binding.sln]
已完成生成项目“F:\halo-comment-sakura\node_modules\node-sass\build\binding.sln”(默认目标)的操作 - 失败。


生成失败。

“F:\halo-comment-sakura\node_modules\node-sass\build\binding.sln”(默认目标) (1) ->
(_src_\libsass 目标) ->
  MSBUILD : error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装 .NET Framework 2.0 SDK;2) 安装 Microsoft Visual S
tudio 2005;或 3) 如果将该组件安装到了其他位置,请将其位置添加到系统路径中。 [F:\halo-comment-sakura\node_modules\node-sass\build\binding.sln]

    0 个警告
    1 个错误

已用时间 00:00:00.28
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (F:\halo-comment-sakura\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "F:\\halo-comment-sakura\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd F:\halo-comment-sakura\node_modules\node-sass
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN sass-loader@8.0.0 requires a peer of sass@^1.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.0 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

解决

以管理员方式运行命令行,输入

npm install --global --production windows-build-tools