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

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

[复制链接]

338

主题

520

回帖

3460

积分

管理员

积分
3460
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
. ]7 x; t* [" B  W
```bash6 N% Y. Z3 _5 S8 G
gyp ERR! find VS
5 {/ P" C1 e! Ogyp ERR! find VS msvs_version not set from command line or npm config
; d, `  N  d  ]gyp ERR! find VS running in VS Command Prompt, installation path is:
" [2 o0 s5 H" g. z) D; m6 Hgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
$ _, B. M4 \- D9 z+ _% B. ngyp ERR! find VS - will only use this version/ d0 f! A' N. A# g  E) ~
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
- i* d) [8 c9 _% Ngyp ERR! find VS looking for Visual Studio 2015% n$ g( [( i; n8 h$ B' i
gyp ERR! find VS - not found: L3 H1 \' F; |, z( r$ u
gyp ERR! find VS looking for Visual Studio 2013
. j& u" O+ F( x1 \* S, ?$ mgyp ERR! find VS - not found
: W2 E% J$ `$ H5 ~4 tgyp ERR! find VS
) K" `, P% b, [/ K6 G& f- f) w& d- bgyp ERR! find VS **************************************************************
  Z- J- T) c9 Wgyp ERR! find VS You need to install the latest version of Visual Studio
/ y2 p0 V1 _5 g3 ^  q" Ggyp ERR! find VS including the "Desktop development with C++" workload.
+ S5 F, W* o( agyp ERR! find VS For more information consult the documentation at:
9 h. d. {) y; N/ K4 Q" i9 Lgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows) K$ Q& f2 Z8 ^1 J$ b$ E
gyp ERR! find VS **************************************************************
% H8 _1 s/ h* C8 G# i) K7 F1 Ggyp ERR! find VS% f, m3 c4 q1 }6 y
gyp ERR! configure error
/ R; A8 n/ s! b+ s7 X% C( w! Rgyp ERR! stack Error: Could not find any Visual Studio installation to use. y& h" ]- Y7 r" r" _5 q& V
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
. m) c# p$ z: Vdio.js:121:47): q% ~9 D( K# l( V% c% j5 z! [
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:166 i% i+ F/ V& J/ q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:163 k8 Y: C, t8 \7 w/ Y9 J& D- k1 Q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7# \# w; X# ?# g6 r3 S, A
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16; W$ I: Y# ~# ]
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
+ M- c! {8 I/ \: j* K: Q' Xgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
8 [& `" h& s4 {gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
  F% U4 e9 ^0 F' ~) p( O, Rgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
. u! V. N7 v6 d0 }9 i4 T- o* xgyp ERR! System Windows_NT 10.0.15063
3 s4 I5 Y: r! k

) H* t, N6 e3 A( C0 `. G8 T: n解决办法% N. X& Y: O% n6 [
1、卸载nodejs重新安装一遍: a. k8 q% r& b$ e( r/ r& B
( L$ Z& \$ `7 J( ~3 w6 P6 Z
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org" V1 X( e  T, B5 x# u3 K
0 j2 g" z  z8 q9 H. b
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools8 _3 b5 U0 V- h# ^% E2 u
————————————————
2 C$ s( M) a5 P0 Y. n' m版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。8 A6 x8 X. n( e+ z) {& s. D
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

520

回帖

3460

积分

管理员

积分
3460
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7( D( z) ~' N7 \8 J. w4 A
9 {2 F1 h9 }  y8 H. T5 S
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
. m: n! B) {- ^: ^8 O1 Z
2 X! A  X. X" r! y' x- |' l' s! W2 i' {然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
$ \4 N! ]$ a! Y, L, o* o————————————————
5 W0 f+ U3 n( n& r1 O/ H+ T- \版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。* U( o* h5 v0 i6 F2 x
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-2 03:13 , Processed in 0.021054 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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