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

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

[复制链接]

347

主题

565

回帖

3689

积分

管理员

积分
3689
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
2 t& j/ A" F& L5 X! G
```bash3 j+ G" G. s5 E4 a4 w
gyp ERR! find VS
3 z( X8 C7 N9 C# C" L; ^gyp ERR! find VS msvs_version not set from command line or npm config5 Z! M! b3 J& t/ i" y  D9 _: O
gyp ERR! find VS running in VS Command Prompt, installation path is:
- m# v, V9 B6 B6 B+ J' agyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
6 n1 i2 Z1 r& x( f( [gyp ERR! find VS - will only use this version
  y& L/ |& p4 V! s+ N9 J+ [7 ggyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
( ]) m% b0 n/ E. h# kgyp ERR! find VS looking for Visual Studio 2015* v3 t; H1 d' T
gyp ERR! find VS - not found+ e8 \- o5 T% l/ x, s2 b0 p" {% p2 z
gyp ERR! find VS looking for Visual Studio 2013
( L& ~0 d. ^# z% c/ M+ P& V& g5 Qgyp ERR! find VS - not found& a' k' T) N! j' Q2 o8 j
gyp ERR! find VS
& U( y; ?( O% k6 R7 Sgyp ERR! find VS **************************************************************
# m3 I3 @6 U' z. x  i; Vgyp ERR! find VS You need to install the latest version of Visual Studio
3 S& s0 y  \( l- {( @gyp ERR! find VS including the "Desktop development with C++" workload.: i7 Q: k/ J& ^/ y
gyp ERR! find VS For more information consult the documentation at:
( V2 D4 O+ P2 ggyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows8 G8 _8 L; e0 z' y( w
gyp ERR! find VS **************************************************************
  a, s$ t+ v) T3 m' p1 [gyp ERR! find VS
3 P0 t/ J5 J) B" f3 A& B% egyp ERR! configure error
! {) L/ `- W# R# Q7 e2 l% {9 g, bgyp ERR! stack Error: Could not find any Visual Studio installation to use! w' ^" K; ~5 x7 E7 }1 U
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
" I; b2 P) e! K$ `/ Y4 W# ndio.js:121:47)) p3 C/ p) K) y9 R, S  x% l
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16* p& ~2 E8 B; K+ \, H
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:166 w" A3 U) V& D6 g; R7 B
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7% M7 I% w/ U7 b. \2 C. B+ j
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:165 o3 h3 S$ L3 ]# k
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)3 A4 t( _- S, }; U  }
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)2 m; _( @/ U3 {9 R
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
8 g# p" e7 B* e/ Z0 u. L4 m: g! Jgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)+ @6 ?1 b6 Y; E# S' g# B. V
gyp ERR! System Windows_NT 10.0.15063

5 d1 a2 I/ D" E0 g* W! U' U: }+ j1 L4 l5 s
解决办法
; [9 ^9 j# ?: C( q$ y6 d1、卸载nodejs重新安装一遍
9 [- q  g3 b4 ~  V" @' `. J3 e. _: [% s
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
' O! G" _( [1 w& w( ]7 G  o/ M
6 w8 Z4 G3 v6 a( g8 _& q: {3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools9 U0 @7 Y' C& I
————————————————
2 h3 l9 ~) `7 H0 |8 @6 h( }版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。2 a' D& N6 k# Q
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

565

回帖

3689

积分

管理员

积分
3689
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7. J+ y5 v9 b- c3 i
& z1 l: c! z; a- r
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。2 m7 B, G3 ~4 C

' r  h" P& |8 l6 C4 G3 i2 t$ G然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!7 v" b; R+ z' _# B2 K. c9 ?
————————————————3 Z6 J2 [' g/ q9 J# H  e: ]. i
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
  T1 G( j) t( F9 F% I原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-20 04:50 , Processed in 0.011962 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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