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

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

[复制链接]

318

主题

482

回帖

3094

积分

管理员

积分
3094
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:2 R9 j4 E& W* ]* ^) D) n
```bash) R( z. C0 }% o& c  m
gyp ERR! find VS2 m; \- p, Q6 X9 T' y' U* O8 G
gyp ERR! find VS msvs_version not set from command line or npm config
; U% l% o* f8 k9 }8 A0 Ggyp ERR! find VS running in VS Command Prompt, installation path is:4 M# ~1 k& T" w( N/ c, s9 e1 `5 l
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
2 r% Y5 h8 G$ l0 Mgyp ERR! find VS - will only use this version, y- n5 K, _- G5 v& u
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer* V- x) V( q' [) C. t* @* f
gyp ERR! find VS looking for Visual Studio 2015
' e8 w: @: t1 M7 n* Mgyp ERR! find VS - not found! Y7 l" G% \" l) I
gyp ERR! find VS looking for Visual Studio 2013, Y, F( P% x* K# r: a
gyp ERR! find VS - not found
) b; @, N+ |1 hgyp ERR! find VS: x4 j# K9 g. t
gyp ERR! find VS **************************************************************
& o2 {" _$ S7 n% Qgyp ERR! find VS You need to install the latest version of Visual Studio
: R+ D/ T. ]( a% s. s( e2 z/ Ogyp ERR! find VS including the "Desktop development with C++" workload.1 O- f  U  _9 A- y# L: T% `
gyp ERR! find VS For more information consult the documentation at:
% O) h# z2 F# z' Z& f+ _7 G7 J' jgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
; ^7 Y! |1 q5 A. ogyp ERR! find VS **************************************************************, |1 y! m6 i6 w! z6 K2 M$ E6 A
gyp ERR! find VS  @3 q# V( c- {! o' `& U
gyp ERR! configure error
! Y1 Y6 B& B2 s" k! X; A, z! a# }gyp ERR! stack Error: Could not find any Visual Studio installation to use. j1 H3 J6 V0 D' Y. @0 }
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
; c9 _$ Q, q6 wdio.js:121:47)
1 v& k3 g: Y: t" n) ]gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
" t- W: @# T/ P7 _# rgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:162 P: C& h' ~! _, Q, c5 d) L& K
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7, j1 S- F6 q6 P% Y: z
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
% z6 g# g- W9 G) @4 Tgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
8 A5 E8 U5 u2 k9 lgyp ERR! stack     at ChildProcess.emit (events.js:315:20)' c) A; l. X- C+ L" {# a- L
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)4 m9 v0 F3 ]7 t, A0 f/ c
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)5 |  |4 e* D2 W- a' G
gyp ERR! System Windows_NT 10.0.15063

1 O" x0 _. F) ~' I, {2 y! ~' B/ Y$ g* P8 w
解决办法
' v6 J0 z7 u: C  A1、卸载nodejs重新安装一遍
2 F% M1 x2 F, U. u) j# F
8 c4 ^: H3 @8 {( U( I  @$ v2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org! `  C; J; D* N% R4 X% R+ P. l6 g

+ b. }2 X% c1 x0 f3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools! w5 ^1 T9 J9 W4 \
————————————————6 d/ o7 K- w$ c+ y' [# _
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
& w! E: ~: {2 s+ x  o$ A原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

318

主题

482

回帖

3094

积分

管理员

积分
3094
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.75 S% o; x- E4 R7 V6 }% J* H0 e- d  @# n

+ m- W; r) R& h$ n& R由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。* X. c  z2 t. E3 D9 T6 K9 t0 x7 K
# }1 F2 h& D$ v
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!2 O- J0 ]$ X2 u* w; e7 ], ]6 {
————————————————6 Y- r" `0 ^% B, n; [" o0 ~* c* f; \. a
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。2 a- R) n7 c: E$ m
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-7 19:00 , Processed in 0.160336 second(s), 9 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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