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

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

[复制链接]

340

主题

529

回帖

3532

积分

管理员

积分
3532
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:1 g' h3 }" H% J" {$ x
```bash9 G& @+ _' H% Y
gyp ERR! find VS
# q0 ~- d0 S  ]gyp ERR! find VS msvs_version not set from command line or npm config7 v( l3 K" N: H5 n
gyp ERR! find VS running in VS Command Prompt, installation path is:
/ `  K: S+ r6 m1 M8 j1 i% zgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
! }) ^; u/ N' g: [6 Q/ o: cgyp ERR! find VS - will only use this version
6 n( z. E% C' {7 H' A0 G6 ~gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer) X2 r& @& h; o* }3 G5 a! _/ h9 h6 f* S$ W
gyp ERR! find VS looking for Visual Studio 2015
3 k) U6 Q6 |: v9 n  tgyp ERR! find VS - not found9 S9 m" X' r1 K( C+ y
gyp ERR! find VS looking for Visual Studio 2013% T* [$ I/ S3 X* ~8 N: j
gyp ERR! find VS - not found7 }8 C9 H+ z  W+ T# w- G
gyp ERR! find VS
* m& `  _7 j) d4 h; Q/ W$ j" [- tgyp ERR! find VS **************************************************************
, s1 B5 b  t- h6 W) y, zgyp ERR! find VS You need to install the latest version of Visual Studio$ u3 ^' D! K, z
gyp ERR! find VS including the "Desktop development with C++" workload.4 y, ^* Q3 T. Y, ?; V8 s9 P
gyp ERR! find VS For more information consult the documentation at:
1 ]7 w2 X% s3 t* V0 F8 ]6 xgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows: M6 }$ [# g1 H
gyp ERR! find VS **************************************************************
3 d9 z5 O' o% f+ H, `5 igyp ERR! find VS8 j1 D* K; d0 a( [& W
gyp ERR! configure error
1 G. s* a. W: h6 N  d9 I$ Igyp ERR! stack Error: Could not find any Visual Studio installation to use$ c( @8 f1 {- H  {1 D
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu6 c0 k# C/ S/ w
dio.js:121:47)+ d; C+ y2 ^8 N
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
0 @4 |$ v, e7 t0 Z. ^. b( xgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16+ \5 b6 g. {# f- u! l2 ?
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7, w' }8 j3 z! A, o0 k% @
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16& c6 X% p. r2 _% _; y# \+ |* ?% p
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
- x, W! \2 ]% n+ igyp ERR! stack     at ChildProcess.emit (events.js:315:20)" m; }9 d8 R8 O& @1 p) u5 G
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
$ p! ^$ I$ F! P5 m6 V) b. ~; Q: z4 F# Ogyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)+ m! z! d6 i4 K, X2 F
gyp ERR! System Windows_NT 10.0.15063
0 F! y* J& W( ]  \
0 ^+ q" A: E7 B9 S, `% x4 o
解决办法
) [. [. B( I2 e3 z, C  l1、卸载nodejs重新安装一遍) u, _2 R: a9 _0 {7 d/ L

. l3 m3 f* p. I1 S7 h2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
. }1 r, K( B: Q5 x+ r, T, w: u9 V
" d+ j9 u  ^' h' d4 A. p9 u. D4 a3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools; U! ~7 ~% `5 c# |2 A$ k2 c% Q
————————————————
8 g5 o% D/ N4 d& Y2 c& d6 H+ Z版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
) X& o$ ]* h; n0 Q. |原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

529

回帖

3532

积分

管理员

积分
3532
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
5 }+ X/ X6 ?/ \4 t
* L9 W. N8 Z. M由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。* D+ \9 \2 o# d* g+ _* }) D
5 f& h( ?4 ^- q$ l$ B  y1 @
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
9 ]( z! ]2 x. A3 F2 x% Y————————————————. Y  J2 v& H! o
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。6 Z9 P3 E# \# _4 v
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-21 06:21 , Processed in 0.012823 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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