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

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

[复制链接]

343

主题

557

回帖

3639

积分

管理员

积分
3639
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
& ]+ b# N& w/ D) o9 l- \
```bash8 u  B; l$ i: ~1 C) q
gyp ERR! find VS
# V% [+ Y/ D& I$ B' ~4 A8 mgyp ERR! find VS msvs_version not set from command line or npm config' n2 e' V3 L7 k" X, T5 r3 Y
gyp ERR! find VS running in VS Command Prompt, installation path is:* C" I% S- [, e
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
9 m3 B3 U3 K9 E) ]. a  Ogyp ERR! find VS - will only use this version7 C! ]) K7 q& q7 \/ C- q. B! a* x7 I
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
7 e5 v6 ~3 k9 B1 q* ?, j. Q0 J* ugyp ERR! find VS looking for Visual Studio 2015+ t# S& P7 x5 L1 N  I
gyp ERR! find VS - not found, e2 E5 T' T8 V- ^$ D9 k' i+ J
gyp ERR! find VS looking for Visual Studio 20130 ?- g3 c, o; A* q5 Y
gyp ERR! find VS - not found
. W. l- p5 H% s$ @gyp ERR! find VS/ r( M' I" V' F0 o' D* i( |: F
gyp ERR! find VS **************************************************************
* @- u- q0 T, M4 K' {gyp ERR! find VS You need to install the latest version of Visual Studio$ T3 V' ^7 ?6 h/ G8 T
gyp ERR! find VS including the "Desktop development with C++" workload.! R$ l- H- E  w$ u! {
gyp ERR! find VS For more information consult the documentation at:
: |! C8 {% t9 J: Y9 M' \$ b+ a& wgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
5 R4 M: W/ c$ K/ T6 T9 n# rgyp ERR! find VS **************************************************************/ o( g' B7 h! j, ?! d- W
gyp ERR! find VS: F6 V! ~, l  M, [/ v
gyp ERR! configure error) g; D+ O$ B) i) o  ~% S
gyp ERR! stack Error: Could not find any Visual Studio installation to use7 Y" J: c: p0 U
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
$ Q+ r' _4 p& ^. ^dio.js:121:47)2 [3 h4 D/ Y, m7 g
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:163 M1 w8 x/ c. s4 s9 O# N. d$ s
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
9 [7 E% y& t7 d5 d( B6 Zgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:78 ]# h9 S9 H/ D6 ?: y
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
$ {/ c4 z3 w5 F/ t, h- l5 qgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
/ A  _4 V$ v! C& |% rgyp ERR! stack     at ChildProcess.emit (events.js:315:20): ?4 O) e7 o6 n7 K7 Y0 m) l% \- q1 h
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)  K" `# g/ ^6 J1 a  n& F
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
; L0 c) l. B  q) Wgyp ERR! System Windows_NT 10.0.15063

4 G; G) Q  e: Y7 ^4 X7 {5 U# J5 i" X1 I  ]$ V3 z3 L- y: i8 N3 m/ J0 O
解决办法# V% }, R  Y+ A4 t. e3 y1 U8 ?
1、卸载nodejs重新安装一遍+ z0 D# {& R& x$ z5 ?3 q

9 ^; o1 f9 ~* x0 ]* R; U2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
" h: a5 A& m+ f/ ~
( L+ B4 {1 t9 M6 W$ ~3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools+ e# }" o# u5 _+ h3 c$ B! y+ C
————————————————$ Q; B3 ]: I0 |" w2 K$ Z% {+ R
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。  `8 N2 T( K! A
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

343

主题

557

回帖

3639

积分

管理员

积分
3639
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7) r5 O( w- P, k3 d

  X' P8 z/ t2 ^由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
  t4 C; M4 H7 G; c
) r- r; Q' x. Z# p. b- d然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!! Q7 \8 E+ w, ?5 J  s4 \  H7 I# _
————————————————
2 y4 [: T% i; `版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
3 A# T2 `2 s+ g8 \2 ?7 o原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-3 07:06 , Processed in 0.015521 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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