windows安装nodejieba踩坑记录

npm install 的时候总是会出现下面的错误:

gyp info find Python using Python version 3.8.6 found at "C:\Program Files\python\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS - looking for Visual Studio version 2017
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2019 (16.11.31624.102) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - found VC++ toolset: v142
gyp ERR! find VS - found Windows SDK: 10.0.19041.0
gyp ERR! find VS - msvs_version does not match this version
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS valid versions for msvs_version:
gyp ERR! find VS - "2019"
gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (node:child_process:404:5)
gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Administrator\\AppData\\Roaming\\nvm\\v16.8.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--module=D:\\DEV\\esop-front\\node_modules\\nodejieba\\build\\Release\\nodejieba.node" "--module_name=nodejieba" "--module_path=D:\\DEV\\esop-front\\node_modules\\nodejieba\\build\\Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93" "--python=python2.7" "--msvs_version=2017"
gyp ERR! cwd D:\DEV\esop-front\node_modules\nodejieba
gyp ERR! node -v v16.8.0
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --module=D:\DEV\esop-front\node_modules\nodejieba\build\Release\nodejieba.node --module_name=nodejieba --module_path=D:\DEV\esop-front\node_modules\nodejieba\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93 --python=python2.7 --msvs_version=2017' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (D:\DEV\esop-front\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
node-pre-gyp ERR! System Windows_NT 10.0.17763
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\DEV\\esop-front\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "rebuild"
node-pre-gyp ERR! cwd D:\DEV\esop-front\node_modules\nodejieba
node-pre-gyp ERR! node -v v16.8.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.5
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Administrator\AppData\Roaming\nvm\v16.8.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --module=D:\DEV\esop-front\node_modules\nodejieba\build\Release\nodejieba.node --module_name=nodejieba --module_path=D:\DEV\esop-front\node_modules\nodejieba\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93 --python=python2.7 --msvs_version=2017' (1)

 

网上的办法都做了个遍,都不行,包括什么清缓存、删node_modules、装windows-build-tools等等,

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

 

后来发现,首先得解决python版本(https://www.python.org/downloads/)过低问题,然后安装最新版的windows-build-tools。

最后把windows-build-tools版本和自己安装的版本对应起来。

执行最后这句:

npm config set msvs_version 2019

大功告成!注意,后面的msvs_version要和你现在安装好的版本一样(2019)。网上写的都是2017, 所以一直出错。

 

参考版本:

winows10

python3.8

"nodejieba": "^2.5.2",

 

参考链接: 

https://www.jianshu.com/p/e546464d6162

https://www.jianshu.com/p/4a45e115a626

https://*.com/questions/65258925/how-to-fix-node-js-error-like-gyp-err-find-vs-including-the-desktop-developme

 

上一篇:NPM 错误收集及解决方法


下一篇:关于Vue脚手架安装失败的问题解决