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

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

[复制链接]

335

主题

520

回帖

3425

积分

管理员

积分
3425
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
, a8 ~: Q5 \  V9 s& e
```bash$ @' C: m/ Z: A2 J! k/ ?3 \. [( \
gyp ERR! find VS- J# _- L8 E& ]0 g; [' T& M
gyp ERR! find VS msvs_version not set from command line or npm config
. r: f( v; I, _! ?" mgyp ERR! find VS running in VS Command Prompt, installation path is:
: G+ [/ l3 x( @$ W. z. t$ z" C4 Zgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
7 ?( h3 P% ~% }( o: Wgyp ERR! find VS - will only use this version
- Z( d2 R/ X9 ^) p- |gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer3 R( r0 Q/ N9 X" g/ s6 V- R! A) f
gyp ERR! find VS looking for Visual Studio 2015' H2 m& ~+ u/ a# ^* i/ @
gyp ERR! find VS - not found: J) D. ]! P  R9 ~
gyp ERR! find VS looking for Visual Studio 20135 i/ ]+ E( o0 N6 j3 H5 w# y
gyp ERR! find VS - not found
. z: J# F2 I6 A3 E! @, _5 Cgyp ERR! find VS3 K$ ?; `0 W/ B# O% P" I0 J
gyp ERR! find VS **************************************************************
; l9 i8 f  o1 H5 Q& X) l% Ogyp ERR! find VS You need to install the latest version of Visual Studio
% e) O% Z: D* _* y1 bgyp ERR! find VS including the "Desktop development with C++" workload.
, R' u( U$ F7 M: `gyp ERR! find VS For more information consult the documentation at:" z. v9 F! I' C* s
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
& S+ e4 s0 b5 {- `5 {gyp ERR! find VS **************************************************************) u8 e8 D  y# `, O
gyp ERR! find VS
( ], C+ P& N$ }! X% x; S+ Lgyp ERR! configure error) `0 S* z' H7 s' c2 H6 l
gyp ERR! stack Error: Could not find any Visual Studio installation to use9 s" a. O. g; j3 G6 W
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu. d  _$ T8 Z7 M+ K2 A  c! v
dio.js:121:47)! K3 a! w2 R1 O4 p$ I% _
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
" t0 _. A8 _# sgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
% E7 o0 f2 `+ G' ^9 kgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
& u5 n9 u( f& D6 t: xgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16* J( U2 O5 }7 P% I# R
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5), ?2 O% A  O4 ?2 {: S
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)' j: T2 t( j+ |, t) b
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)( b. _- \( X, H+ J% @# R" J
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
7 O5 c) e) I& M9 X- W) Tgyp ERR! System Windows_NT 10.0.15063
1 Y6 H9 @1 f# E5 f! h4 _5 E

( @/ q  C; k7 V2 T解决办法- q: p; I5 v5 I7 b
1、卸载nodejs重新安装一遍
0 r9 S# `# Q) J* W. l! D
7 G. w+ r" X- X0 Z( ~2 O2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org& S- _5 ~8 T* M" M
/ l  ~7 D" @# X
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
' s) p; P6 j/ ?% }  c8 x————————————————
4 G4 w! @# ~; L2 U: {' i: @5 T3 K/ q$ ~版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
. f1 Y# R* L/ W) U* W% J) T- B5 ?原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

335

主题

520

回帖

3425

积分

管理员

积分
3425
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
; b; x; O9 Z% f$ l& h$ f5 s4 r. W- N. v+ z$ e2 h3 F9 f
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。% E6 ^3 {9 V9 f4 ?. r8 ~2 V

- Y, {6 K! a& D' c然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!+ y$ Q  C8 U( m7 k1 g; U
————————————————
1 y. X9 |: `6 b版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
. T5 d# o; }) v4 S原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-13 18:15 , Processed in 0.082025 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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