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

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

[复制链接]

338

主题

520

回帖

3456

积分

管理员

积分
3456
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:3 p4 [+ }9 X  h! \
```bash
! d6 J8 ~6 a9 w9 H' j, zgyp ERR! find VS) z8 y' Y. @( C  |0 Z& M0 j
gyp ERR! find VS msvs_version not set from command line or npm config
  r7 J1 y" H: B. k* N! Agyp ERR! find VS running in VS Command Prompt, installation path is:+ ]; [8 L9 Q# a) x
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
& X: ?6 d) H. C, h  V+ u* [gyp ERR! find VS - will only use this version2 m# z# n3 A: v$ W2 e1 H+ M
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
/ N; r+ T- `8 r6 I. q' m& a* _gyp ERR! find VS looking for Visual Studio 20158 R4 \: a3 {) R7 y
gyp ERR! find VS - not found
* W3 ^2 n. q; I3 |+ n: b! kgyp ERR! find VS looking for Visual Studio 2013
7 r& H! j" Z$ \0 u8 K* K6 l3 [gyp ERR! find VS - not found& P7 j& U/ z' b* i6 \+ g/ [+ V/ T  B
gyp ERR! find VS
5 h# [) l4 c% T; y( |" p- S1 ^gyp ERR! find VS **************************************************************
2 Y" P$ L) F8 ~+ Y( s+ y9 _gyp ERR! find VS You need to install the latest version of Visual Studio
- y9 ^! {' G3 m& m/ T7 {" ^gyp ERR! find VS including the "Desktop development with C++" workload.; \4 J0 u" r0 }+ V/ G5 q
gyp ERR! find VS For more information consult the documentation at:2 F5 q9 k% W; h- U7 Y& [; r1 G
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
# K5 v8 R) W  ^/ V7 e/ wgyp ERR! find VS **************************************************************
  ]: C8 F$ ~! I4 x' Q9 m* N! hgyp ERR! find VS
" Q( N6 M  h# f3 {  `& lgyp ERR! configure error, F  a: a. h1 E; v# C
gyp ERR! stack Error: Could not find any Visual Studio installation to use: l: M7 e6 G% e- e7 V" A
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu0 ^) R- h. S+ [: D" P
dio.js:121:47)
1 m/ P' `7 u% ~6 a4 agyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:161 \7 o( v: ?/ F) v) p& l5 X
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16  s- H1 p& S3 j  T# g$ o& u8 j4 {
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7: f$ u9 b3 T' z
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
* G/ W3 o1 Y% U9 t4 L5 ^gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
: C+ _1 i5 k# @$ Z* X' E2 j0 J. vgyp ERR! stack     at ChildProcess.emit (events.js:315:20)6 C. J9 @) d8 e1 Z; m; X: [/ }
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
$ y4 g; m9 m; B& P; C# sgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)& q! N& x8 S% w( C8 a
gyp ERR! System Windows_NT 10.0.15063
0 h4 B; V( y6 I6 v4 C/ B5 _
! h# _' g# X2 {9 p: }! c* d( ?
解决办法
8 E& t- k  X# g$ J& ]3 ]* F1、卸载nodejs重新安装一遍
5 B; j1 `# q! K# h* v8 x
8 ^- p1 ]2 N) [& x2 ]. r2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org( R4 x$ _8 V5 y* t  E! O9 I* g- i  k

/ b6 u3 ^8 [- m7 R) i' U3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools% `( l9 g7 v( j' d
————————————————
! c; c  k2 B! h, s版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
  X  }  v: p$ R原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

520

回帖

3456

积分

管理员

积分
3456
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7) X. b( ]8 Y9 j! q8 }+ H; X
9 D: ^( S# o7 `" K- c8 m9 E
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。3 h% S. Q6 k7 |5 K' ~
  a+ E- `6 F( t8 j, z* f# l
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!) x% @6 g9 `1 H3 |4 o; }
————————————————- Q! C( U- v9 R+ n- ~
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
( j- z( s. t9 V/ e9 s原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-29 11:10 , Processed in 0.034556 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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