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

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

[复制链接]

331

主题

511

回帖

3343

积分

管理员

积分
3343
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
" d9 Y& c# {) X
```bash
& W7 q: G1 F  `% F' y9 kgyp ERR! find VS
7 Q4 x5 d9 K4 |$ egyp ERR! find VS msvs_version not set from command line or npm config
. j2 X" E0 k' {. Pgyp ERR! find VS running in VS Command Prompt, installation path is:
' {# U# B) P$ f2 Y" @7 \gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
* i* W  k% m0 G4 {8 ^' sgyp ERR! find VS - will only use this version
5 n0 R! k& H7 f4 w9 y4 fgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
; B2 h' n7 K/ t) ?" w" @2 y: B3 R5 Rgyp ERR! find VS looking for Visual Studio 20152 N) Y) X" f: Y# L" f
gyp ERR! find VS - not found' ?! ~2 e4 q  e, C9 C2 U0 [3 C
gyp ERR! find VS looking for Visual Studio 2013
1 n' T- H. {& m' s6 v) x0 v  D! Pgyp ERR! find VS - not found
# h- L0 x8 I# x8 m# [gyp ERR! find VS
! }% ]# g4 w5 @4 a* e7 A6 cgyp ERR! find VS **************************************************************
0 v7 f6 x# g" |6 i1 D4 Tgyp ERR! find VS You need to install the latest version of Visual Studio& b/ p8 J9 B8 m" v( ]% U- ]4 |  d
gyp ERR! find VS including the "Desktop development with C++" workload.
* ^% H+ ^; H9 a# V3 c, I$ ?gyp ERR! find VS For more information consult the documentation at:
1 C3 ^6 c) n( f3 j% Ugyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows! _( o9 z! S* _4 t$ Y) l
gyp ERR! find VS **************************************************************
+ [" K" K3 w( V# o' J" R  mgyp ERR! find VS* q  X% i2 K, ^/ T9 j0 P+ k+ t
gyp ERR! configure error8 C5 r$ V" G6 d' q, x% x
gyp ERR! stack Error: Could not find any Visual Studio installation to use1 S3 A# B+ e$ v7 D6 E
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
8 ]7 s+ f6 q" [! Q% C/ hdio.js:121:47)4 c( N! ~# J) g# h( J
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
+ v6 d  y/ U9 {% H9 egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
& E' d9 f( E& N: [) f$ vgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
) o; O% @, I9 ?4 c- x5 W* ugyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
: L5 R8 K" z- @gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)- X% ~3 m: W8 }- k' Y. }
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
) @/ P: ~( B: |gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)  C: X' t, ^3 z4 {8 D( J3 W
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)% v+ \8 s* x: c" ?/ J$ @' ?) X& o
gyp ERR! System Windows_NT 10.0.15063
0 J& p% [' E# J- O7 C0 M
2 b( o1 g- O1 ~1 Y' \! k1 ]
解决办法. V4 C- X) e# z2 |+ N' S1 F
1、卸载nodejs重新安装一遍- f) E& F& T7 r2 _4 a1 g

6 j: t3 p4 X) w! b' R9 S5 Q6 A$ X6 W/ S2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
5 P! i- n! F6 L/ m2 q# |8 Y+ q' N6 y$ B; e1 ]6 C
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools" K9 w0 l1 i; k8 ^2 Z2 \! V
————————————————
+ n. V! |# U4 S2 ?9 w8 X1 `版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
: Z3 b3 G, X' h. e原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

331

主题

511

回帖

3343

积分

管理员

积分
3343
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
/ s8 c: n; {8 A/ k0 H( `3 @  h+ t  F8 ]; m/ |6 P/ U1 m$ g
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。0 x) M; j  d& g3 I

& f5 v$ d' z9 Q* S: O7 b9 p然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!& x9 a' Z/ u, R+ ?1 k- Q$ X
————————————————
5 t; x* E% _+ Y! K0 z, @8 L版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。) x% t' k- `# F# I% T
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-9 00:07 , Processed in 0.088545 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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