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

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

[复制链接]

343

主题

554

回帖

3627

积分

管理员

积分
3627
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:; a. K  ~" X* e9 K; y
```bash* H1 Q* b* y* j4 G" k! t
gyp ERR! find VS$ O: T+ R* y: u6 A" |# Z5 o
gyp ERR! find VS msvs_version not set from command line or npm config
7 \$ C& I! V/ `0 Q( u3 P/ igyp ERR! find VS running in VS Command Prompt, installation path is:$ y2 g5 ~; d8 H6 j
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"& |9 \  Z6 w/ t3 a
gyp ERR! find VS - will only use this version+ v8 t0 z# D5 S  m
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer3 U' A" h4 Y6 d
gyp ERR! find VS looking for Visual Studio 2015
% L# p6 p# [& k% V1 g* x" ]9 Mgyp ERR! find VS - not found2 X( z- _! |& q0 J3 Y: F
gyp ERR! find VS looking for Visual Studio 2013. d" U% y2 I6 ~1 U" d( k$ A4 ]
gyp ERR! find VS - not found- ^6 `) T2 w+ L2 F
gyp ERR! find VS
( h  s" E+ M+ s3 ggyp ERR! find VS **************************************************************( B& I& @) i. M
gyp ERR! find VS You need to install the latest version of Visual Studio! X  V0 e5 i$ o
gyp ERR! find VS including the "Desktop development with C++" workload.
; B' N4 c. J  V* Cgyp ERR! find VS For more information consult the documentation at:
) V1 S, u2 g, t3 \gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
) f8 o: n5 M; b% Vgyp ERR! find VS **************************************************************9 Z) q3 }& f) d! o  D' O9 V
gyp ERR! find VS
" S! R9 G! f! }4 {& v/ N' ^gyp ERR! configure error4 S! E- K$ O! ~2 ?% n% i
gyp ERR! stack Error: Could not find any Visual Studio installation to use
9 P: @7 k2 a1 V5 `# b. ^gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu6 o5 H3 s6 m7 Y& y. Y1 F; m$ k
dio.js:121:47)' t+ @3 v' F2 G3 Z) V
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:162 b% _8 d! j/ @
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
2 o- B: k7 m7 T, b1 l# |gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7* B8 r* s. Q/ z3 a1 l4 U0 f8 k( d
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:169 C" E  W( f! K% q* ?& j2 d$ w
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
8 w) F" I: G7 M8 P/ k; Y  y% bgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
: m3 ?0 p7 y$ B9 f: hgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16), A# |7 a9 s1 v; {! R
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
. O5 s7 O) H, R. D+ G2 H# xgyp ERR! System Windows_NT 10.0.15063
8 v$ s- @: H1 M6 d
! P0 d' t5 ?9 g5 V5 g- z2 w+ v, v
解决办法
9 P! H! C) f& X1、卸载nodejs重新安装一遍  C7 s$ m7 T9 x' m+ V9 P) u8 p
. S' P" T0 k7 ~8 _# o2 j2 ]
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org/ k, b" `! L) r. ]" ?) H

5 G: T" C+ A3 D) C5 M% ]3 k3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools; Q$ n" d* t6 p- @  o
————————————————/ ^9 K* T9 R& X
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
  y" }8 o* o5 R1 j( A原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

343

主题

554

回帖

3627

积分

管理员

积分
3627
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7" |& u/ u: k, a% E# b: H) ~. q: u
. c/ H) L( l) M0 j
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
4 t0 |% C7 t$ |! \  ~3 S/ g) S* N+ L/ ?, j+ d" W. }1 O$ y/ q0 d+ u9 l
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
( d" [6 l* @: h! ]0 X  C# f( F+ p4 M————————————————
8 Y+ `  a# g) p; w, I版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
  s; ~$ f) \4 q* L9 ~9 ^原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-1 16:33 , Processed in 0.021129 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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