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

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

[复制链接]

346

主题

559

回帖

3656

积分

管理员

积分
3656
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
- B0 r+ m% [# _8 n- a
```bash
$ p. n/ l5 }8 C3 A/ C; p& v9 Cgyp ERR! find VS
4 A! M2 V' G. \* |# F/ ogyp ERR! find VS msvs_version not set from command line or npm config
% }6 `8 Q, J; C' {6 F4 vgyp ERR! find VS running in VS Command Prompt, installation path is:
  i7 w! ~) t; X+ qgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
, A& D2 I+ e: l1 o4 Z- }  S" Xgyp ERR! find VS - will only use this version
7 K9 V0 ~2 P3 k. l& y  xgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
/ _; J  Y, `# i3 z. mgyp ERR! find VS looking for Visual Studio 2015
  S8 a% O+ f) q% ^5 Dgyp ERR! find VS - not found4 L" j9 F' C0 o1 Q9 q& G) r1 u
gyp ERR! find VS looking for Visual Studio 2013
7 d( ]+ @4 H2 k# M0 C* Lgyp ERR! find VS - not found% h; }0 B8 U/ ^8 h7 t! i
gyp ERR! find VS
. z: Y# l% r2 i5 [; Y- a5 W/ Vgyp ERR! find VS **************************************************************% Q/ X: c  O7 N( S: T, v
gyp ERR! find VS You need to install the latest version of Visual Studio/ d- ]% t. S% d/ R5 K
gyp ERR! find VS including the "Desktop development with C++" workload.
3 f$ O4 W& O! ]$ y6 e7 }$ Agyp ERR! find VS For more information consult the documentation at:, k/ V+ B; z4 ~
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
7 c$ g: S" i. f2 W& M( X, Tgyp ERR! find VS **************************************************************. N3 d9 p& i. t5 M& k. E
gyp ERR! find VS8 F2 q* t2 D( X- }0 Y
gyp ERR! configure error7 s4 N1 e% u) m5 q: `' x- s
gyp ERR! stack Error: Could not find any Visual Studio installation to use
# ?  ?' T$ B& F" x, n% ggyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu- f1 T# b* b% _
dio.js:121:47)7 d3 @' V5 l0 ]4 Z$ i" i, u
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16( @5 \0 b1 o6 q/ E4 D; |1 V2 w% |
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
% q) o# _* B" F# Zgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7# J4 n  ~* U. n- j) E. y; w4 O3 X
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16, Y( q( z: E7 n* b: q1 I
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
' B: Z; D% k8 p' ?gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
. O2 m. W1 \5 P) B% O; _- fgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)0 B" V. K( f* ~  z6 X% |
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
1 ^# Q7 h' c1 B4 N# Mgyp ERR! System Windows_NT 10.0.15063
$ A! A9 a0 V, K: r

. e9 }- ~8 `# r解决办法4 Z# P1 U& \8 W; N
1、卸载nodejs重新安装一遍
( U# Z! R" h4 O& |( k5 ~; r6 T  @4 ^0 c  L# f' y
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org% x1 |6 c0 K) n: X
% h7 j2 ?9 C; X3 K& |( F
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools/ p1 s7 I$ S9 [  ]; r' h% B: z! Z
————————————————
' c+ v  X4 D) Y! c; l- P版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
6 e* ~8 @: P$ M' W  h原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

346

主题

559

回帖

3656

积分

管理员

积分
3656
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
( i9 b8 @+ F8 M: L$ T1 d; m  q: V0 ^
5 Y7 j+ m$ Y7 K& H2 ?" y# x由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。* k% Y# \6 b! t" y* w
4 c+ E. b  o- J8 U7 D* O0 G
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!6 B0 H& t; W+ L4 K3 P9 g
————————————————
! @* X( ^5 ?( {7 w( [" `0 r版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。) c* @$ O+ f5 D2 m8 q+ G/ d; o* N" ]
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-4 03:54 , Processed in 0.012394 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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