npm install齐天大坑!!!gyp ERR! find VS msvs
•
前端
报错信息:
```bash gyp ERR! find VS gyp ERR! find VS msvs_version not set from command line or npm config gyp ERR! find VS running in VS Command Prompt, installation path is: gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017" gyp ERR! find VS - will only use this version gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer gyp ERR! find VS looking for Visual Studio 2015 gyp ERR! find VS - not found gyp ERR! find VS looking for Visual Studio 2013 gyp ERR! find VS - not found 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 (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu dio.js:121:47) gyp ERR! stack at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16 gyp ERR! stack at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16 gyp ERR! stack at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7 gyp ERR! stack at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16 gyp ERR! stack at ChildProcess.exithandler (child_process.js:310:5) gyp ERR! stack at ChildProcess.emit (events.js:315:20) gyp ERR! stack at maybeClose (internal/child_process.js:1021:16) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) gyp ERR! System Windows_NT 10.0.15063
解决办法
1、卸载nodejs重新安装一遍
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install –g –production windows-build-tools

4、关键所在!!!执行编译时指定python版本,npm install –python=python2.7
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/1b4972c43c.html
