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

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

[复制链接]

331

主题

511

回帖

3355

积分

管理员

积分
3355
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
% s* {, L' n6 x  b' t
```bash! m' s" t1 K( ^, p+ u2 x# z* R) p
gyp ERR! find VS
/ I5 |" [' b& V: z, K& J/ Xgyp ERR! find VS msvs_version not set from command line or npm config
7 S( w0 W# b+ sgyp ERR! find VS running in VS Command Prompt, installation path is:
" P- K# r0 p3 }9 Qgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"9 l% L5 E# `9 q7 b0 X( K
gyp ERR! find VS - will only use this version% ?( N- v% b6 u1 [! y# n* M
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
, p: v1 i) F7 kgyp ERR! find VS looking for Visual Studio 2015  P0 Y8 w  w6 g
gyp ERR! find VS - not found* |% Q. e1 H! c! t* ~
gyp ERR! find VS looking for Visual Studio 20134 m, f/ a5 z% W8 A7 r$ P
gyp ERR! find VS - not found* _6 B/ Z% p& g
gyp ERR! find VS% ^" J' C$ }' G& o9 e3 M' u
gyp ERR! find VS **************************************************************
0 B. e' v3 g! Y6 J1 ygyp ERR! find VS You need to install the latest version of Visual Studio
% P0 s, x3 e- M) O! Vgyp ERR! find VS including the "Desktop development with C++" workload./ U1 Y1 @! K* A8 b& W  M8 z( }
gyp ERR! find VS For more information consult the documentation at:4 P5 ?0 W8 ]/ {7 o* O9 l
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
7 J1 y5 O' Q% J, Z2 l( o1 e* A$ }( Ngyp ERR! find VS **************************************************************
9 y6 L( p/ g; Z8 u! c/ Qgyp ERR! find VS4 g! a  Q3 D1 h% o" e' I
gyp ERR! configure error
+ p. }6 _( E' @' [# vgyp ERR! stack Error: Could not find any Visual Studio installation to use
$ o6 |2 W+ Z- J( }6 H$ {% p5 `gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu6 E+ ?5 G3 k+ l# A. k# L
dio.js:121:47)
; k+ K- V1 P4 f6 N% L7 |" s2 ^5 Ygyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16' `0 a; A0 A! }- F! p' ?# Z4 K
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16; |- Z) M! `7 R( \  i; I8 k' A
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:74 |- z9 V. h, H+ @# e) B1 @" i
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
/ J* D0 S+ h. `7 |gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)8 W7 Z2 M! h$ Z$ J" w
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)4 S4 M6 ]! m+ c* }. ?
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)/ d: \& @/ L( p7 |
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)4 I9 J- N, U  z. ]2 W( E
gyp ERR! System Windows_NT 10.0.15063
; \) ^! _( v% B. l; V/ L  e* S
3 F) X$ z, R- E6 t5 L
解决办法
# d; ?, D5 @& _, D1 a1、卸载nodejs重新安装一遍
, r  R2 {+ W. {& a# \% V3 n; J- E
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
' e1 [  f! H& m8 m# E
3 v; Y3 K+ P( h3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
1 \& T# K+ n0 r3 s2 A: m4 D/ F————————————————
8 n+ F) c- {' h3 G8 Y; z" U1 L/ U- j版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
2 d3 I; e8 D) ?: \) Z; O) i原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

331

主题

511

回帖

3355

积分

管理员

积分
3355
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7% H- o, _9 q5 f3 ], I
/ k/ v8 A9 E% e7 G6 b7 v* v1 w
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
! e. X6 s/ U7 m0 r; ^. \& F, ^( J- o$ i, g) _$ a9 i2 F
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
- T' c, _- |9 H5 ?, ^2 n" C————————————————, Z) u8 Y, @4 P8 g9 U* ~
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
6 u% x0 W0 F5 J1 I+ F原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-20 18:26 , Processed in 0.076333 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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