异常:关于node-gyp

很懵!感觉很突然,之前还是好用的 最近在npm install之后项目就不能运行了。【具体造成的原因还不知道(难道是因为node\npm升级了导致?),希望有遇到的大胸弟能指点一二】

问题:

异常如下(这还是缩减版【手动笑哭.png】)

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:\company_project\xiexin\trunk\app\xxsdapp\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\which\which.js:80:29)
gyp verb `which` failed     at F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\which\which.js:89:16
gyp verb `which` failed     at F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at F:\company_project\xiexin\trunk\app\xxsdapp\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:\company_project\xiexin\trunk\app\xxsdapp\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\which\which.js:80:29)
gyp verb `which` failed     at F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\which\which.js:89:16
gyp verb `which` failed     at F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at F:\company_project\xiexin\trunk\app\xxsdapp\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:\\company_project\\xiexin\\trunk\\app\\xxsdapp\\node_modules\\which\\which.js:13:12)\n    at F (F:\\com
pany_project\\xiexin\\trunk\\app\\xxsdapp\\node_modules\\which\\which.js:68:19)\n    at E (F:\\company_project\\xiexin\\trunk\\app\\xxsdapp\\node_modules\\which\\which.js:80:29)\n    at
 F:\\company_project\\xiexin\\trunk\\app\\xxsdapp\\node_modules\\which\\which.js:89:16\n    at F:\\company_project\\xiexin\\trunk\\app\\xxsdapp\\node_modules\\isexe\\index.js:42:5\n
at F:\\company_project\\xiexin\\trunk\\app\\xxsdapp\\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` succeeded python C:\Python27\python.EXE
gyp verb check python version `C:\Python27\python.EXE -c "import sys; print "2.7.15
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.15.0
gyp verb command install [ '10.15.0' ]
gyp verb install input version string "10.15.0"
gyp verb install installing version: 10.15.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 10.15.0
gyp verb build dir attempting to create "build" dir: F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\node-sass\build
gyp verb build dir "build" dir needed to be created? F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\node-sass\build
gyp verb Not using VS2017: Could not use PowerShell to find VS2017
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\node-sass\build\config.gypi
gyp verb config.gypi checking for gypi file: F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\node-sass\config.gypi
gyp verb common.gypi checking for gypi file: F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\node-sass\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [ 'F:\\company_project\\xiexin\\trunk\\app\\xxsdapp\\node_modules\\node-Dnode_gyp_dir=F:\\company_project\\xiexin\\trunk\\app\\xxsdapp\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\curry\\.node-gyp\\10.15.0\\<(target_arch)\\node.lib',

在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
生成启动时间为 2019/2/21 9:56:01。
节点 1 上的项目“F:\company_project\xiexin\trunk\app\xxsdapp\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 Studio 2005;或 3) 如果将该组件安装到了其他位置
,请将其位置添加到系统路径中。 [F:\company_project\x
iexin\trunk\app\xxsdapp\node_modules\node-sass\build\binding.sln]
已完成生成项目“F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\node-sass\build\binding.sln”(默认目标)的操作 - 失败。


生成失败。

“F:\company_project\xiexin\trunk\app\xxsdapp\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 Studio 2005;或 3) 如果将该组件安装到了其他位
置,请将其位置添加到系统路径中。 [F:\company_project
\xiexin\trunk\app\xxsdapp\node_modules\node-sass\build\binding.sln]

    0 个警告
    1 个错误

已用时间 00:00:00.27
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:\company_project\xiexin\trunk\app\xxsdapp\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "F:\\company_project\\xiexin\\trunk\\app\\xxsdapp\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=
" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd F:\company_project\xiexin\trunk\app\xxsdapp\node_modules\node-sass
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

看到这异常,内心N只***。但是异常还是能看懂的。

  • 首先 python找不到;
  • 其次 很明显的中文提示: 未能加载 Visual C++ 组件“VCBuild.exe”;
  • 最终都是与 gyp...有关的(之前从没有注意到这个插件,也不记得安装过此插件 ·_·)

解决:

通过科学地搜索node-gyp, 发现github有详细安装此工具的步骤。github地址

此处仅列出Window环境安装:

  • 安装gyp命令 npm install -g node-gyp (项目莫名的已有此插件,跳过);
  • 安装Visual C ++构建环境:Visual Studio构建工具
  • 安装Python 2.7(v3.x.x不支持),安装后要配置环境变量。成功后执行npm config set python python2.7
  • 执行 npm config set msvs_version 2017

上述步骤全部执行且成功后,项目恢复如初。

你可能感兴趣的:(异常:关于node-gyp)