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

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

[复制链接]

319

主题

484

回帖

3115

积分

管理员

积分
3115
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:& m4 ?  {$ ?* I( f5 ]  @: g
```bash
5 v; [) w: Q/ Igyp ERR! find VS3 V7 }' f5 ?" i0 x2 o6 L# Y
gyp ERR! find VS msvs_version not set from command line or npm config6 J5 I3 v4 e' H% d8 C. c- u. r6 l
gyp ERR! find VS running in VS Command Prompt, installation path is:5 c0 O0 R8 |+ I, M6 p( P% q) R& ^: [
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
7 h  X. t7 I) V& h. M8 d4 [: Bgyp ERR! find VS - will only use this version& T6 Z' O: p* o7 `
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
: `$ x) P. {2 e4 A. [gyp ERR! find VS looking for Visual Studio 2015. l; K4 l  d7 c; n
gyp ERR! find VS - not found
2 Q7 D( L" V; e9 e3 Kgyp ERR! find VS looking for Visual Studio 2013
& v; d+ O0 j# F+ m& Agyp ERR! find VS - not found" a2 C7 H- E! o( G; p8 r
gyp ERR! find VS& s3 G7 `; h6 n2 g) B% W; v  v0 s
gyp ERR! find VS **************************************************************# {  L; N  S7 j- I) \1 P
gyp ERR! find VS You need to install the latest version of Visual Studio
& j" z- v- K! M! S4 V$ E, sgyp ERR! find VS including the "Desktop development with C++" workload.
) b- W# H9 r7 W' W  zgyp ERR! find VS For more information consult the documentation at:8 G6 S" T% z5 d
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows0 [7 x7 Y* B: o2 k7 |
gyp ERR! find VS **************************************************************
/ _$ C% m! {/ o! K* Y: G6 [gyp ERR! find VS8 U; V- L! P" I% O9 p" \& B3 Q7 |
gyp ERR! configure error
, E9 P! T6 W: t4 `" Igyp ERR! stack Error: Could not find any Visual Studio installation to use: \* X9 x6 k/ z0 C; V; |2 g
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
$ P) g6 Y$ g7 w2 o# C9 hdio.js:121:47)
( b) u3 P( Q6 k, `4 fgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16% y. L- x1 P5 {  L1 ?/ n
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16+ c8 G. a# j$ `) J7 z
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
9 y  x& w8 H! _6 Ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
0 d( U! a: Q! M! J5 v- Ggyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)- ^. y  B( O' Z5 M& k7 W
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)8 ]1 A4 m( Q4 M2 `- `4 W& @
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
: U. H: n1 i. X+ g* \4 @gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
8 I' g8 T7 M9 h. }$ P. Dgyp ERR! System Windows_NT 10.0.15063

, }9 G. \* ~; O0 l
% ?* @3 q4 k2 ?1 p' r7 a5 [解决办法
  S; Y3 j& G' W& I1、卸载nodejs重新安装一遍
( w  O, A" I0 e# o
/ D/ f5 J2 E6 |# w: t8 d$ ]5 R2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
: a% ]- q. @: u8 }% v6 U/ L! ]: X, e
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
/ ?/ A8 W: n4 J7 B3 J3 u" M/ I————————————————: |4 H( n( D% ?5 K, I- P
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
" `% F& f$ F6 o原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

319

主题

484

回帖

3115

积分

管理员

积分
3115
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.77 G1 V% |. i8 P6 {/ Y4 |, I$ S

1 }$ Q" D- b) S& \* z6 N由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。( v9 O) r' [% C2 m$ J0 s2 c
/ R% L. C8 A% l' I6 R& p( v
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!/ h5 {; t! K, f
————————————————8 ?2 n( y; c5 h9 |9 p$ c
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
. k; m3 I. g4 ]3 T% F1 \7 k原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|通达产控投资 ( 粤ICP备2023021749号-1|粤公网安备 44030402006137号 )

GMT+8, 2025-7-1 06:19 , Processed in 0.068450 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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