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

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

[复制链接]

343

主题

550

回帖

3613

积分

管理员

积分
3613
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
9 t! `  `8 ]9 v: d, J& o
```bash! j! v+ i- v* Z$ b6 J0 [4 i
gyp ERR! find VS
& z) f# `  R" Q+ {gyp ERR! find VS msvs_version not set from command line or npm config6 {4 ^5 L9 M( u% }9 b* n! n
gyp ERR! find VS running in VS Command Prompt, installation path is:
5 k4 o& n6 x$ W9 Hgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"' T' ?3 k' u- N0 |' P6 z
gyp ERR! find VS - will only use this version0 @' b5 D+ Q2 E2 x" m4 s% v4 T3 O: N
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer9 h5 w" f8 k& p: g  m  |
gyp ERR! find VS looking for Visual Studio 20155 n( I0 m! `& ]: `+ N
gyp ERR! find VS - not found5 U( l3 t3 O7 S% ?, Z, T
gyp ERR! find VS looking for Visual Studio 2013, v6 N$ u7 k  W4 j5 t
gyp ERR! find VS - not found
5 b3 D3 {+ v0 Wgyp ERR! find VS
1 c, E# q, d6 e8 R5 I! \/ Ngyp ERR! find VS **************************************************************
0 }. x# F* _! Q! O2 ]/ }( Ugyp ERR! find VS You need to install the latest version of Visual Studio. [# ]( D( p% u% |3 o
gyp ERR! find VS including the "Desktop development with C++" workload.
$ M8 ]9 K3 q' t  b4 x" _: t. Vgyp ERR! find VS For more information consult the documentation at:2 \6 r7 G: ]  @/ D
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows4 ^; y, B+ D) {% Z
gyp ERR! find VS **************************************************************! Z$ O0 m5 D' n2 ~1 ~. O
gyp ERR! find VS9 h" K0 j. l( ?+ \7 B; D
gyp ERR! configure error4 S5 B; Q' V& l
gyp ERR! stack Error: Could not find any Visual Studio installation to use
5 d4 H/ @0 l7 n( o' V) |9 a* q8 Xgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
$ N$ \0 x& S3 ddio.js:121:47)2 p: h% t- p+ {5 q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:164 L7 p' T/ ^* x4 n
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:162 \+ j7 |' i+ r9 [; ?# ]5 L
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
1 D1 P/ a4 ?; y2 F! Egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16, L* A6 a2 x# F9 I
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
6 l# v& [. d/ o5 |7 }gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
" l; ^* F* d! e3 Egyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
6 n  y9 G/ }6 I. B5 Sgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
2 l& u1 ]6 t' tgyp ERR! System Windows_NT 10.0.15063
$ {* }. b# L; P. z: S

4 s1 l. h  ?1 A$ f解决办法
4 s0 l8 f4 a3 D8 W% g1、卸载nodejs重新安装一遍- g0 n4 E- R; `

" P7 a% F0 z2 \7 x3 Q6 [2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org5 ~( Z0 \8 w% \6 M1 R4 i- r

' Y: I" x5 p2 |/ l& J3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
' I% i) Z) f3 a) N" I+ g/ D! \————————————————
: s, z+ ]* U: t7 S$ _版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
% ^! D; D. L! L- R原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

343

主题

550

回帖

3613

积分

管理员

积分
3613
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
& f; v# w1 G, o' }1 c5 l/ A6 d" I
1 s- n' x3 M8 V, [由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。& I3 Z; i* j  }0 i2 x. z
* X5 V' l2 B9 W' f0 B% O9 Y
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!: e9 I2 b( P. D. j; c) j' q% u
————————————————
; R9 A* w) k6 k  u9 ^  ?  B; X版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
9 j2 F- f- ~" P7 t: C$ @& L9 I' ?. |原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-31 01:37 , Processed in 0.015681 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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