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

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

[复制链接]

340

主题

526

回帖

3516

积分

管理员

积分
3516
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
( R" `* J9 G' n) W) F- Z8 V
```bash
' ~5 N; G0 r+ I+ I: J7 ]& Pgyp ERR! find VS/ r! Y9 A' j& D, I
gyp ERR! find VS msvs_version not set from command line or npm config
0 J0 k5 M$ {- [" G+ ]& v! B0 Sgyp ERR! find VS running in VS Command Prompt, installation path is:
. t: C& a, N# }, k9 Ggyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
3 D: v4 G" C" t$ K4 K2 Hgyp ERR! find VS - will only use this version/ E" ~4 j# U! h3 }  ?2 V' q/ Z
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer0 V: D4 @: {, \, p# C
gyp ERR! find VS looking for Visual Studio 2015- q2 S, j; ]3 W# D3 x
gyp ERR! find VS - not found) A* r, }" h' n* r. @, V
gyp ERR! find VS looking for Visual Studio 2013
; z" J) m* [4 E0 Z$ egyp ERR! find VS - not found* e" m$ X6 B5 U/ `# y# P
gyp ERR! find VS
  J' k$ R$ j; K$ C7 `  agyp ERR! find VS **************************************************************$ U/ E) K$ S# c+ H9 w9 W9 G
gyp ERR! find VS You need to install the latest version of Visual Studio
' {: W3 o. B; }- L, t" agyp ERR! find VS including the "Desktop development with C++" workload." T' j$ `/ \! |' e  _
gyp ERR! find VS For more information consult the documentation at:! M1 R4 h% E5 f5 D. o+ M/ x
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows' o6 P( j5 U; y# c
gyp ERR! find VS **************************************************************6 W: K2 W6 B; L8 W
gyp ERR! find VS
- G: h' s9 w5 j$ e2 L6 Q/ ]5 mgyp ERR! configure error
* T; `7 o5 z8 J+ J3 u7 pgyp ERR! stack Error: Could not find any Visual Studio installation to use( d, l- y5 D- s- i& ?4 Z
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
$ T/ Z0 E0 w0 w9 k2 sdio.js:121:47)& F5 N# t3 |# K9 ]2 M4 v7 s- f% D8 {: J
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
2 d( k' E- o1 A3 l8 W5 n1 ^gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16* L. [. |' }" Q3 _0 |! e3 f
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
. q3 q: c3 ^8 ^& g- Vgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
/ Z! d. v' P- I0 i' w0 v7 o  \! m0 {gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
/ p7 s0 y& x2 a- `2 ~% pgyp ERR! stack     at ChildProcess.emit (events.js:315:20)* o( h+ K+ x/ p5 N% w/ B' @% ?
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)% @  }3 M6 L  P' o1 g6 H1 a
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)1 g" I: ~* W0 m
gyp ERR! System Windows_NT 10.0.15063

1 p* l6 H1 [) q
+ _2 B' j# Q/ M* I7 c( ]解决办法
5 X3 C: u5 _- Q, K: m9 h6 @* a- X1、卸载nodejs重新安装一遍- c% P1 ^  W: e* v3 u. z5 z8 Z

# t7 s; ?3 T% B$ f( U! O9 B2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
# Y# Y# W$ [) {- y  e  C3 X8 O0 l2 v- L: g
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
& H4 `) `: t) G) O————————————————; y. k% i# x$ K- k7 n
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
; `# p$ i% F& e  y7 L) H原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

526

回帖

3516

积分

管理员

积分
3516
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7* l4 g3 ]. \: m# t

7 P  y! r" H8 W" l由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
  X; I3 I0 @3 f1 X' l2 d
: B, y) Z% C5 C# s) x1 D$ _然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
5 C$ G% S  g7 R% x& x- G, R+ d2 u# ]————————————————  ?& Y6 Z8 G. ~  M
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
- s: K4 j6 r' `  J( U* Z  D原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-15 10:57 , Processed in 0.024420 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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