找回密码
 立即注册
查看: 2591|回复: 1

npm install齐天大坑!!!gyp ERR! find VS msvs_version not set from command line

[复制链接]

527

主题

676

回帖

4608

积分

管理员

积分
4608
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
8 k* R" `7 @/ c, J& F
```bash& ]0 b  N2 i7 r4 ~
gyp ERR! find VS
6 o# Z, ?% P4 k, N/ ogyp ERR! find VS msvs_version not set from command line or npm config
- p8 B/ x  O  s2 f2 s* p! kgyp ERR! find VS running in VS Command Prompt, installation path is:
: t% T' x9 k0 H& P6 i# `gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
1 S7 M! W0 L2 w( m  ^8 p$ V% zgyp ERR! find VS - will only use this version
! J# o- F2 T( y+ ^gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
6 n5 `9 ~/ G  f1 u. _gyp ERR! find VS looking for Visual Studio 2015+ f0 b1 Z5 ~; c5 {# G: J) b- g
gyp ERR! find VS - not found6 ]: M3 A) g1 _+ y! F7 M# a
gyp ERR! find VS looking for Visual Studio 2013
3 k/ o2 }6 {4 @6 p% ?' A( K( ^) fgyp ERR! find VS - not found1 d5 d' g! J$ k  \+ o0 x  w0 a
gyp ERR! find VS- o6 Q8 x" b! S
gyp ERR! find VS **************************************************************; `3 N7 g$ i" w0 e( b
gyp ERR! find VS You need to install the latest version of Visual Studio/ I2 F9 u0 ]3 X3 j/ y4 y
gyp ERR! find VS including the "Desktop development with C++" workload.& H: [- U+ `; j* m: p
gyp ERR! find VS For more information consult the documentation at:
3 v1 j% s8 P! G( K0 @& Ygyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows- H7 Q; B) k* k& h! m4 P0 |) m
gyp ERR! find VS *************************************************************** @, u4 W, f- C; B$ e
gyp ERR! find VS/ o/ [5 G$ ~! }% o' `) D: f/ \* f
gyp ERR! configure error
+ Q& f( c" i! G9 F! r% v6 Y5 m& Wgyp ERR! stack Error: Could not find any Visual Studio installation to use
7 c4 b0 C* V* Tgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu2 J6 `8 h$ H, t  o( r6 G. i
dio.js:121:47)
" K; F& O, b' x  jgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:163 T$ a6 y* o/ G$ ?/ Z
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
: N9 @' u& \1 Y. C0 b: ^gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
9 M9 w9 D. ~: w" D+ rgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
6 u9 W: _0 P, C, D; ?1 zgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
# V4 I# i4 Y8 G+ Ugyp ERR! stack     at ChildProcess.emit (events.js:315:20), ~: e1 p% I& o; P7 J) t
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
% f0 f1 c7 c  n" H4 Fgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
( j6 t9 w$ Z" l6 Z( h( H* ggyp ERR! System Windows_NT 10.0.15063

6 c, Z5 q9 K. E& W9 s
5 @2 [, q3 s% b& v解决办法
7 n8 }4 ~+ I+ E- I/ `1、卸载nodejs重新安装一遍
) k" {9 Z" n) W# w; M5 S* o/ {- \; E/ a. B& M$ o' _
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org% e3 e( o9 t4 ^8 c  W
5 U' v8 }$ h, |5 ^; j2 W. P
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools8 ]" b  W1 C" y5 y
————————————————2 r- A& \8 }; c7 |
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。4 b! \6 ^6 H* q; S- @: ?" S0 u
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
欢迎定制:13928122889
回复

使用道具 举报

527

主题

676

回帖

4608

积分

管理员

积分
4608
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.77 s7 H3 a3 [5 H, |
* v( D9 o+ O8 N7 ]
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
9 b/ {6 e1 ~" m
8 M% T8 R' ~( p$ O然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
2 ^$ w/ L, r; J/ x( I* Q6 W; N————————————————
9 {! p$ _3 ?6 j0 X2 A版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。/ K2 o5 u% ]( d7 N; ?, y
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
欢迎定制:13928122889
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|通达创业无忧交流社区 ( 粤ICP备2023021749号|粤公网安备 44030402006137号 )

GMT+8, 2026-6-24 06:11 , Processed in 0.020455 second(s), 4 queries , Redis On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表