找回密码
 立即注册
查看: 1473|回复: 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 | 显示全部楼层 |阅读模式
报错信息:3 ?. V7 Q8 a4 N8 P4 P/ l, C
```bash
7 n$ I  P8 u8 a: \5 L. n* tgyp ERR! find VS
1 J) T8 i  u) F. \5 ^$ }0 W3 kgyp ERR! find VS msvs_version not set from command line or npm config% I) g( X% p2 @& Q) l
gyp ERR! find VS running in VS Command Prompt, installation path is:, e7 v" B) r" h5 ]* e4 B4 |% z
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
- z6 g6 s& I, Qgyp ERR! find VS - will only use this version. C5 j9 W0 [  Q! C
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, p- c, l& i2 K6 T, [
gyp ERR! find VS looking for Visual Studio 2015
, h8 R' f: O& g0 v; N- |3 `* |) lgyp ERR! find VS - not found
/ ]3 V: O% Q6 H1 [- A- u4 }gyp ERR! find VS looking for Visual Studio 2013' G  ~5 I; d  e, |) Q) ?$ ^) J
gyp ERR! find VS - not found) e  }: B" t+ Y* c5 i) _3 \
gyp ERR! find VS
1 N% [; F" y* G4 Q5 Zgyp ERR! find VS **************************************************************
- Q" m8 G8 B# q) X0 X6 }* t7 [gyp ERR! find VS You need to install the latest version of Visual Studio
; ^# H2 z% u: ^* ~gyp ERR! find VS including the "Desktop development with C++" workload.
4 m5 P9 v4 N6 Tgyp ERR! find VS For more information consult the documentation at:& @0 W$ ]7 ?8 r
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows9 D/ P9 J$ ]  i# H
gyp ERR! find VS **************************************************************
5 l' j& b  ?! p! ^: Y( X! U5 wgyp ERR! find VS
+ n9 k* ^2 E) o7 Tgyp ERR! configure error) ^- z) [* a& o% q% D- _( R" z6 B
gyp ERR! stack Error: Could not find any Visual Studio installation to use
, d' {3 z; [" @! ygyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
+ n! x& s8 S" I4 g5 S' ~dio.js:121:47)* T* L3 h" H" M: X6 J$ [9 H2 z9 @
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16) W! X# s2 a5 j
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
* p" }8 G( c) b2 B. Mgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
# Q8 F& b1 @& w8 P4 Ugyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
: e; A$ Y2 ?" Ygyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
) W: I0 a5 s8 z3 d4 A( ygyp ERR! stack     at ChildProcess.emit (events.js:315:20)- t  x* t+ m6 [/ N0 C3 ~" p# d$ q/ c
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16): x7 W" g0 }. o% O
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)9 N3 c$ n* r* t; t8 u
gyp ERR! System Windows_NT 10.0.15063

0 |' d' H1 [# F9 c: t. \" A% J0 _: H" t# P; e' F# o
解决办法
9 _" k+ z9 K8 }, X# P1、卸载nodejs重新安装一遍; }' K$ v1 t, v& R# Y! l
' n0 `1 g5 P/ e; O9 v2 w
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org* X, g% A, H  @; j3 z* V& m% g7 J
" c( S; z% s$ p1 [! O- v
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools' X4 e# o' }/ Q$ u: ?, o
————————————————
9 ~3 M) @% ]. b# @) L版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
# Z/ l1 Y; _2 r1 s1 ^7 S原文链接: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
' k3 N) P0 B! D) o5 @, T5 K
7 F* M. B5 B# N7 J" I, n, D由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
) e5 Q- Q  \9 B9 E2 H6 y4 [% u6 v
4 M7 S* a. y# X! g7 z1 X' x然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
0 b5 b" {: B& a7 n————————————————
& s$ n2 v3 R2 t% Q) c* `版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
2 |& d& ?: ]; D! a原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-1 01:55 , Processed in 0.014784 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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