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

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

[复制链接]

340

主题

530

回帖

3542

积分

管理员

积分
3542
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
3 n9 I/ b3 o) {: t+ l
```bash- h7 O$ `5 \. s8 M
gyp ERR! find VS
: a2 K, n& c- U6 B9 N* }; sgyp ERR! find VS msvs_version not set from command line or npm config4 x4 Z3 V* g* v1 R& i
gyp ERR! find VS running in VS Command Prompt, installation path is:
8 [4 o: A- x' Q$ y, C# R3 J3 @( w3 lgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"; i# s$ i( [6 ]9 @
gyp ERR! find VS - will only use this version7 g. X( Q" F2 n; Z
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
$ R4 {, Z9 W' i  C+ Y+ s0 pgyp ERR! find VS looking for Visual Studio 20155 e0 \, t# ^1 Y# @) b# |! w& g
gyp ERR! find VS - not found
0 Z& _2 i8 z' K7 A! Xgyp ERR! find VS looking for Visual Studio 2013, s' `0 [% O1 E+ e& d  t7 e1 K& C5 s* P
gyp ERR! find VS - not found# H# @/ q) D8 l3 Q
gyp ERR! find VS
! C4 `- a" l5 H/ Bgyp ERR! find VS **************************************************************$ X2 O, K- I" r) j: E: l
gyp ERR! find VS You need to install the latest version of Visual Studio
% @0 `- Z( {, A* W' M! x! xgyp ERR! find VS including the "Desktop development with C++" workload.$ ]+ R, y4 Z0 z- w; Q+ T0 P& [
gyp ERR! find VS For more information consult the documentation at:
6 r; U+ ]$ x' L3 h  Jgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows) x- A! [& |3 s) \
gyp ERR! find VS **************************************************************0 d2 ]5 |4 N0 A, S
gyp ERR! find VS- U: t( j, p9 C! u: C( f9 ^8 q
gyp ERR! configure error
. v% ]! R. G8 u5 v& Bgyp ERR! stack Error: Could not find any Visual Studio installation to use
, @" E3 R/ t5 b* W* T% |8 _gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu8 e6 o4 g5 {0 d# ~$ m$ z
dio.js:121:47)6 [. _: f1 i: B& I! a
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
& r& G! s0 O2 G5 g. }! ugyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:166 C0 m/ T1 i! `  `# V1 R/ q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7+ W& ~( y. N6 ]
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16  \( L% w; X# H9 \  P. k
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)9 h( K9 ~* m- P5 p' f6 a
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
  m' K4 U2 Q4 f1 ]5 s7 rgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
# k1 f% r( `6 m! Lgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)( f/ b# z& R) m4 [( i. M& F% O
gyp ERR! System Windows_NT 10.0.15063
3 ]- b. S1 i1 R6 i
, d: ^' M0 Q. _0 z+ L% p
解决办法
  P6 d% M" t7 g; y+ w1 L1、卸载nodejs重新安装一遍3 g% H6 v5 k, O% I2 \' N

, @1 I2 E6 t1 U8 h! ~# \, z  D2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org7 u9 {5 {3 z5 x+ Z" h+ A

0 A. |5 f1 v. J( {1 A" T3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools- |+ z. [! u2 l/ n; W2 y9 ]% y3 O
————————————————
1 F& n/ ]3 ^+ c2 y  q6 D) a! A版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
# R: u' j3 `' L; m4 r  X. @+ W+ B原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

530

回帖

3542

积分

管理员

积分
3542
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7" K6 {4 j* I: y6 a* ^8 [
# s# k/ v4 Y) S4 i
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。1 y' ]( w9 f- ^" u9 u3 N2 m( z: u, {
! N( H: M9 @# F" n% y
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!+ e( C( @+ [  w! q4 U. V
————————————————
6 x0 k. K/ P, ~5 l" j' [  k! ~版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
- V1 g' u7 M, T/ D- k% G+ x原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-23 07:14 , Processed in 0.024636 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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