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

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

[复制链接]

347

主题

565

回帖

3685

积分

管理员

积分
3685
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:* _8 j; O, n; j) r* f( P
```bash; b6 }8 O5 X  ^/ v+ X
gyp ERR! find VS) E1 ?& d& ~% O) T+ o: ^0 t
gyp ERR! find VS msvs_version not set from command line or npm config+ S6 c" f- N- m1 y$ e: W
gyp ERR! find VS running in VS Command Prompt, installation path is:; X- X* ^( e) ?4 L( M- M
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"3 K( o( n( z1 ^2 m# z
gyp ERR! find VS - will only use this version) q: {) i; ]8 x
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer( Q$ O: u' v$ [; J( a) W
gyp ERR! find VS looking for Visual Studio 2015
7 D$ l+ T7 [. Ngyp ERR! find VS - not found- {: g( t: U* q
gyp ERR! find VS looking for Visual Studio 2013
8 b, {8 ^3 `- T- y9 ]6 Ugyp ERR! find VS - not found+ j* H* W1 y. a9 [. u' e
gyp ERR! find VS" Z, J+ j5 K! e0 q) D
gyp ERR! find VS **************************************************************
$ C1 L1 e. J) }8 e1 {& P) Ggyp ERR! find VS You need to install the latest version of Visual Studio
3 \6 X1 L, \4 }  \* ^; Xgyp ERR! find VS including the "Desktop development with C++" workload.
) r0 f% |& H0 |, F% Sgyp ERR! find VS For more information consult the documentation at:  a! G0 F7 B" K- g; F
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows$ @6 \& n0 @  ?' ]. m* j6 A
gyp ERR! find VS **************************************************************; i2 h4 }" |8 v
gyp ERR! find VS7 t; j! J  b8 F5 q6 X' ]1 i
gyp ERR! configure error6 ~  i8 u9 |( `* Y
gyp ERR! stack Error: Could not find any Visual Studio installation to use
% i0 f$ V2 B% j2 [( ~) `5 H  }3 rgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu7 b% d; y' T6 ], C6 A: f+ @
dio.js:121:47)" F# \2 _% M* ^& O3 E5 `; R; ]1 O
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
6 X  J' H$ @4 I) R( Q+ N: F. Rgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
/ Q9 `. K7 G2 p& {! e* I8 E5 Dgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7. c* S: F( [9 j; L& Z1 }: x
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
9 o+ d4 J' E2 z4 u* u" ogyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)5 n8 `* V5 c4 H1 F
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
2 J) h' w! L; Hgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)9 u6 ^" p* S$ ~$ M5 B$ Y4 s
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)& Z1 L  r( F6 {) r+ c& m
gyp ERR! System Windows_NT 10.0.15063
: Q, S! J; p8 ?, C# ~: N
- L4 t" v: L. H
解决办法
, r6 O# u! ?5 U. [% a+ B1、卸载nodejs重新安装一遍( T9 |; t2 U8 b2 s: p

$ ?- a; u& U  d9 E: u. B2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org6 }1 a7 N# s8 m# b% i

8 O8 R  v. ~8 I& ?+ i. q3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools% `8 u5 T! W* }6 R& z& T. D9 F2 u
————————————————
+ ~2 r5 U! q; M6 ~版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
6 G; x# ~% `! c原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

565

回帖

3685

积分

管理员

积分
3685
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
4 ^& i7 N- e+ i' u6 r; h+ O& m4 v0 w2 S, Y! i8 o! `* {
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
7 G* a3 a0 R4 H! D: m/ w7 ]; H2 V- n2 g! E) F, j7 N; x
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
3 D  m: E1 q8 H' F- ?* w————————————————' M9 R0 u+ \3 E4 K) E0 P9 P
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。. C. J  g  ]: v; w) X' Z6 i2 p! X
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-15 22:55 , Processed in 0.012934 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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