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

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

[复制链接]

341

主题

541

回帖

3571

积分

管理员

积分
3571
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:, e: s  X% ]- V! r! q
```bash# G" L# h; q" ^9 w; X
gyp ERR! find VS6 z( ]' v% L* e, c0 V* ?( i  `0 I
gyp ERR! find VS msvs_version not set from command line or npm config
2 f* e, b# ^9 x1 H. \+ u( m( lgyp ERR! find VS running in VS Command Prompt, installation path is:
3 c' ~+ e+ g) [1 B. D- xgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
- E, z* W; z" o1 n, A+ P7 Hgyp ERR! find VS - will only use this version( x3 e: Z% n2 `% i+ ~2 h: T
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer8 S, w2 G, Q7 v. |8 R9 ]
gyp ERR! find VS looking for Visual Studio 20158 W- H6 J4 D# ~! ?5 A
gyp ERR! find VS - not found& z* U! Z9 v3 l5 Z
gyp ERR! find VS looking for Visual Studio 20131 s7 [- C" O2 @* b+ _2 }8 G
gyp ERR! find VS - not found- b" M7 J; j+ V
gyp ERR! find VS
/ @9 L9 \1 t3 ^% i% y, ugyp ERR! find VS **************************************************************
' s7 F3 }9 K7 z; e/ U; Cgyp ERR! find VS You need to install the latest version of Visual Studio# r$ }: |# v! t* s7 ~+ k" h+ z
gyp ERR! find VS including the "Desktop development with C++" workload.
: x4 ~3 N: @3 N8 F. U6 k4 xgyp ERR! find VS For more information consult the documentation at:
8 ?) E: p/ p1 ]% l! U9 \) `gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
2 h- t8 t' m0 A. I3 m( C  ygyp ERR! find VS **************************************************************9 T" S: e8 z( }
gyp ERR! find VS2 a+ W6 K5 i5 ~' q2 E$ ~( T2 l0 Q4 |
gyp ERR! configure error& L6 [  B/ N/ x4 D
gyp ERR! stack Error: Could not find any Visual Studio installation to use( p, b: |0 x  t" f" Z! d& k% f- ?; l
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu( j& x1 J. w6 m/ n! o6 v1 [. p: E
dio.js:121:47)+ I/ ^8 P" |! _, a+ P; s
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16% l2 L* W( g7 ]  ~% t
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
( i% I1 [8 i5 Z% a% ]& R% |gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:79 q5 n2 L3 B! f0 {) ~- A( P/ P( r2 W
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:161 J, o& L% [& f  ], e) M0 I$ e% j' z0 x
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)# [2 @" \" ~. o$ o
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)+ e9 U' V9 j: }
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
- s' {1 c( i, q: o" ]gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)8 Z: O, R0 b' g7 U% G! s% I
gyp ERR! System Windows_NT 10.0.15063
, Y5 s* ~8 q( r9 f

# ?- }: E/ x! T解决办法5 g/ E. V6 ^" ?$ q0 S
1、卸载nodejs重新安装一遍3 J8 P6 _/ h: t6 u" n

$ J) |- F# N1 |5 q0 n% l2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
. e$ j2 k# J  b. |
; E2 L$ X8 C6 V1 `6 Y7 s; C3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools& j9 c9 U7 _$ H; L' Y
————————————————' v1 r2 ], i" \, E$ [- }2 l+ }! n$ }
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。: x# i4 \) \# o9 z* X3 \; `
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

341

主题

541

回帖

3571

积分

管理员

积分
3571
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
2 v4 F. f) M7 s$ N3 _- Q' p( w- t5 W+ W. j+ P; O1 W8 N/ `, \
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
0 x- M/ F. N5 {8 E; X5 G: s4 m$ ~9 J' v2 J! f5 u! ^: G
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
0 A9 |9 W+ J/ y# c" H————————————————
$ h$ `) l8 X; Z0 J5 R' r: f版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
4 U4 o2 n# L2 s7 i+ ^原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-24 16:04 , Processed in 0.014296 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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