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

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

[复制链接]

341

主题

540

回帖

3565

积分

管理员

积分
3565
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:/ r$ |' Y2 ~. |0 ^
```bash
4 @4 @% m- `5 Ygyp ERR! find VS
8 i5 S4 f; a! \+ g) X; Q6 q; h/ sgyp ERR! find VS msvs_version not set from command line or npm config7 m, n4 g, u6 a+ ~' p
gyp ERR! find VS running in VS Command Prompt, installation path is:
/ P5 l; G  u: K  j, _gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
# X. }  C" }8 u. ?& ~% d% x' v/ n4 lgyp ERR! find VS - will only use this version$ `, W1 x  w( \( O' z6 j: S( s
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer  _8 j. @/ u# f8 R4 v" h; w1 m3 z! S
gyp ERR! find VS looking for Visual Studio 2015
9 x: U5 h/ @1 a" b3 dgyp ERR! find VS - not found
. H6 W, q8 d; R& b' ?: wgyp ERR! find VS looking for Visual Studio 20133 q+ Q- I5 \4 O# m" U
gyp ERR! find VS - not found0 _, M3 z" x: k8 t' e# h
gyp ERR! find VS
& b- p- k& r$ ~( x$ R9 R+ o+ Agyp ERR! find VS **************************************************************3 E7 d( b: G1 y* c( o
gyp ERR! find VS You need to install the latest version of Visual Studio
) j7 T# v5 W; S# y' {- Ngyp ERR! find VS including the "Desktop development with C++" workload.
: Q, J- p1 W( M; z& t8 K& J$ tgyp ERR! find VS For more information consult the documentation at:+ _: V- `% r) j( m( Z' R
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
% j- ?  `# o6 Q( g, L* y1 lgyp ERR! find VS **************************************************************/ u; V8 G) I4 Y! |# e* B6 D
gyp ERR! find VS2 ]- ?8 W, c  E2 u& k4 h' P# |( d
gyp ERR! configure error. [$ c, |. k8 Z' o0 D
gyp ERR! stack Error: Could not find any Visual Studio installation to use
4 \" W5 P* G* N1 J  Q8 rgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu7 \* w* m/ w. |  E0 G2 D+ g* v
dio.js:121:47)
& g4 N! C# w% C7 C2 [# U( {. v3 }$ {# \gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
3 K  @/ M( P- F) qgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
0 L0 I; r) n4 _+ M- |gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:79 t8 }3 E8 _& `  s+ A6 d8 H
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
, L* N' L! s# H4 b9 bgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
! f/ B$ B3 Y* Pgyp ERR! stack     at ChildProcess.emit (events.js:315:20)( W4 z  j% S, A! o, s" c
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
* W+ ]1 [! u. U) x  V9 Pgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)8 w9 @" m/ I0 Q" p. t# y
gyp ERR! System Windows_NT 10.0.15063

1 ~! ~- e: z, T2 ^1 z& ^9 k
! o: ^7 J  A& o8 Y6 F" I解决办法) [( Z# x. G) V( }
1、卸载nodejs重新安装一遍* b3 d- a/ j7 A% I9 R7 C. m) l

) A8 e; i0 B# z2 ~; V& C4 l+ \2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
7 J# o& ^( G% z; M. D  p+ B, V" T6 \- n5 J6 [) Z2 N! O0 C5 F
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
  m+ @3 N( O9 ?) C# P- @————————————————
& s5 a& q' X0 L. p8 @: P! w版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
& h/ a, E' Y. c1 f原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

341

主题

540

回帖

3565

积分

管理员

积分
3565
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7& t) @) K: v) p) ^5 e8 d

0 l; `( X7 Z/ R. c5 M1 \由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
7 j7 I9 E1 [+ K2 `7 r, B8 Q, ]. A" d( z9 L$ Z+ N
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
$ e9 }9 ?" v  S8 ~' R% ?: x* {. N————————————————# L% ~9 C( R1 T5 i
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
7 Q: V2 L( u+ T$ B9 a原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-24 07:48 , Processed in 0.012304 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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