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

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

[复制链接]

347

主题

564

回帖

3679

积分

管理员

积分
3679
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
% F; E6 p5 n( d8 T7 r" Z
```bash9 F& N* Z. N  s. k( o4 m7 G' F# }' |
gyp ERR! find VS
8 X& p0 U6 v! Z9 y; q! Agyp ERR! find VS msvs_version not set from command line or npm config; T- [! w. e# W" ]1 \
gyp ERR! find VS running in VS Command Prompt, installation path is:
( _% p7 o; ?" Y5 k% ~2 Agyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
3 d8 A: X/ y' P: _gyp ERR! find VS - will only use this version
& P% R7 J  R& T0 n) M& O0 s& Mgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
9 O" k6 k+ L* ?5 x7 p: ]gyp ERR! find VS looking for Visual Studio 2015
* E3 X4 }  X# d: H* N3 X5 _gyp ERR! find VS - not found: z& E& T1 @: y! s$ b
gyp ERR! find VS looking for Visual Studio 2013' L) ]) |. I2 N  `/ m4 K
gyp ERR! find VS - not found
7 s: t( U- W5 _/ y6 Q9 Sgyp ERR! find VS
% ^6 k# n' _7 ]- r! M. f6 Mgyp ERR! find VS **************************************************************
; G9 K+ T1 Z3 R3 o- o9 Q- Wgyp ERR! find VS You need to install the latest version of Visual Studio8 Y' M; K: N* ~5 Q
gyp ERR! find VS including the "Desktop development with C++" workload.
: d' @0 f( T" |' ^$ b3 v/ D! P4 [gyp ERR! find VS For more information consult the documentation at:  [- ]6 |7 H6 l
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows! I/ O2 F$ R1 l
gyp ERR! find VS **************************************************************
& U" U/ Y& c4 X( i$ [0 ~5 Wgyp ERR! find VS
; [$ G. s  W& \9 G  agyp ERR! configure error
2 z1 }+ F8 m" `gyp ERR! stack Error: Could not find any Visual Studio installation to use
! G3 L- O$ U8 W* L0 V7 w: V5 ~gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
7 ]+ @9 A9 U  zdio.js:121:47), O9 ?% Q2 W+ {7 {0 x+ Z
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
0 E& f( A4 m6 sgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
4 v; ?3 U, H8 S; H" _/ z% `  }4 y' egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
( c. Z0 V1 @  |( x1 O9 ]) Zgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
; G) ^$ T4 i9 w0 t0 T; c+ z  Hgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)+ Y! R# p8 k6 ]6 ?
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)  t; `  R* P. M
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
( Q5 P, Q# K) Egyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
2 d6 [- Q. E- O4 D  o6 V: Xgyp ERR! System Windows_NT 10.0.15063
2 o4 j% c( j7 r( \# C; l& ?4 K

- d: V% u; H/ s3 V; A+ I解决办法
* C' p) E7 T; t4 m8 A8 C6 d1、卸载nodejs重新安装一遍
% f9 R/ |9 ~% d& r! @1 v8 Y- p: O$ L5 f, {* F2 D
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org: K. H  g6 k, H$ _  n2 T9 N
2 C/ ^0 @* t  [+ T0 L
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools6 m4 F2 V& X1 I3 ]( Q% U# B, S
————————————————# x1 v' v6 @" I( u# _+ c, r; f  v
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。- m/ r% x  b! n5 k6 k6 o% T
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

564

回帖

3679

积分

管理员

积分
3679
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
0 L0 I& x% g. Q5 N5 C/ x4 c$ U& Z( }: P
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。8 M9 e- t4 Q4 P( M
$ m2 b! l4 v1 f9 ^5 U$ [" a
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!) W. X0 x5 i4 ?+ |: a0 I
————————————————
  s# S* k( B* G2 U; H& p版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。: ?8 j3 t, K. t- V
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-8 16:43 , Processed in 0.011947 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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