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

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

[复制链接]

346

主题

563

回帖

3668

积分

管理员

积分
3668
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:' `1 [2 r- L1 m' z2 p1 d: B1 M! U
```bash  K8 D+ ?1 B& N3 d5 ~7 R& N+ R
gyp ERR! find VS
5 e5 B, y: r2 J  u1 Tgyp ERR! find VS msvs_version not set from command line or npm config
: U) ~$ `6 h  i- J: [: Z! \" agyp ERR! find VS running in VS Command Prompt, installation path is:
& |% j$ G, o7 N9 ]$ T' p2 @3 lgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
( \3 i' ^2 u3 ngyp ERR! find VS - will only use this version, _* k. P  |- u* h3 U  f
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
  R5 n- V! B5 \, X7 fgyp ERR! find VS looking for Visual Studio 20150 @2 i2 ~5 s- O- q5 Q
gyp ERR! find VS - not found: m+ n: g) h* ]* x2 T
gyp ERR! find VS looking for Visual Studio 2013/ c+ v! q; g; u; ~
gyp ERR! find VS - not found
, r% x# L1 A8 O1 Ogyp ERR! find VS
# i/ g8 {+ r" |" vgyp ERR! find VS **************************************************************- w8 s& R' S" P
gyp ERR! find VS You need to install the latest version of Visual Studio, Q5 T; k& T) s4 X" M$ h: J  q
gyp ERR! find VS including the "Desktop development with C++" workload.
! a& B0 r6 d' ?) Dgyp ERR! find VS For more information consult the documentation at:
" E3 G+ R  T0 E$ f4 w4 x1 vgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
+ Z- [5 H8 v, q$ J/ r' ?gyp ERR! find VS **************************************************************
) w0 k3 l4 i( \% Y4 t! n9 Sgyp ERR! find VS
2 @7 |; Y' X$ n9 b, N* s9 @# Ogyp ERR! configure error+ `$ P$ o* W$ h* q4 e9 W, w! Y
gyp ERR! stack Error: Could not find any Visual Studio installation to use6 Y$ r6 o% z; q. N0 O( a2 x2 D
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
. p9 ^( F6 w: E/ A+ `0 e; C. x$ ]- udio.js:121:47)1 }" s. b/ ]* B  c- H: Q  V( L
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
1 x* O2 [; g$ `# Igyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
  C+ _2 E4 ^! ~4 c; `7 Mgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:71 j! r1 E( y" N" }; t1 Y+ V
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16& k0 P1 M8 d3 D/ }8 f( N- [
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
* ^: W/ r# p  r; T! @5 a+ ngyp ERR! stack     at ChildProcess.emit (events.js:315:20)
7 Y" F2 ?5 }# T! \gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)$ k3 u4 M' `+ }! [9 T
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5), Q, f; \3 S3 D8 r' B
gyp ERR! System Windows_NT 10.0.15063
% S' P: e4 R0 u8 d/ n, S

; F" H/ k2 y' M解决办法
: S7 u3 A/ W' Q, q' s! F8 W! h1、卸载nodejs重新安装一遍6 E* E& _  T& P8 |$ Y
9 V% {  \7 w, T+ j: S! p; \% q. `
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
1 u0 V4 ^( p. V# ]! c  k: N
& y, l& x+ f7 \0 h% V; e3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools$ l& V$ f2 t9 e! x. [
————————————————0 A' P4 k/ a. F4 x$ i
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。- S  t! D. x$ H* s- M
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

346

主题

563

回帖

3668

积分

管理员

积分
3668
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7* S1 r6 W5 a7 q6 }+ K

; _5 i+ {2 n& B3 P# t由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。7 l, O6 D( ]3 W6 J7 u% V

1 `# j$ }" I( c. i6 d" @然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
) _$ }" V  w3 P! G  Z————————————————
& n1 Y+ S5 B1 ~5 t6 D* y版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。% m! d# P/ u1 J3 |2 S! C' u
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-6 13:40 , Processed in 0.010938 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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