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

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

[复制链接]

319

主题

485

回帖

3133

积分

管理员

积分
3133
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:2 Q1 w! z/ H  F3 o
```bash
& m+ F# s* v+ |5 G& }$ Igyp ERR! find VS* E+ \+ _" A5 ]* ~8 N1 k
gyp ERR! find VS msvs_version not set from command line or npm config
3 T) p1 s+ c4 T+ m2 pgyp ERR! find VS running in VS Command Prompt, installation path is:
" L) g! b# m/ T; L! C. _0 A) g, egyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"* p: p* d1 r0 R; j" m. ]
gyp ERR! find VS - will only use this version
8 z" f4 P" @+ ~4 k: h# |5 {1 hgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
' I# c8 Y7 ^- q$ \9 bgyp ERR! find VS looking for Visual Studio 2015
6 v5 ~" X+ S' R6 u/ n& cgyp ERR! find VS - not found! u3 L- p8 H) i2 {
gyp ERR! find VS looking for Visual Studio 2013
& @4 ?1 x1 I7 d, q2 a, y- tgyp ERR! find VS - not found
" v! Y1 s* U3 g! q+ X% T* e, b% rgyp ERR! find VS
0 t1 t: G% v/ Xgyp ERR! find VS **************************************************************9 r  j) x( C; A4 C
gyp ERR! find VS You need to install the latest version of Visual Studio3 a* W! r. Z/ Z; ^; Z1 f9 g
gyp ERR! find VS including the "Desktop development with C++" workload.
" x2 n4 b- t& x: v& N" K# Q6 Mgyp ERR! find VS For more information consult the documentation at:  @7 @5 M# B" o% J/ \) m8 W, Z
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows( i+ j: n9 W* S
gyp ERR! find VS **************************************************************
; k+ m, h' B/ @gyp ERR! find VS% k/ U, w2 }1 D' e5 e4 Y* u
gyp ERR! configure error
! u9 h$ |! l) |% [- T7 N4 ygyp ERR! stack Error: Could not find any Visual Studio installation to use
" J6 J  ~7 w* e  W* [* d* vgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
' ?! k3 P7 H+ L$ Odio.js:121:47)
4 O2 W% y- Z) ~! }. |( j- d4 ygyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
+ {+ k5 A/ A: dgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16) H  q( U" ]4 W
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
4 ^& w$ \: n* G4 \  J5 Vgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
( a6 j% H7 d  ]  x/ Y, @: S. {gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
5 p% U/ T6 i& `2 w3 m6 _8 w' jgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
' w. R# H4 j% t" n7 Vgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
6 m9 Q5 i0 q5 n/ }3 Rgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)9 W6 ?( n2 _1 p: l" F, M1 j! ]3 @
gyp ERR! System Windows_NT 10.0.15063
- i) Z  v6 n- v. x$ P# V
5 R" C7 L2 D+ y; P7 a
解决办法
9 n0 S' r: K% j, K5 M' l1 j1、卸载nodejs重新安装一遍
& o- l$ Y, a- Z: q/ O
. x! [7 p% \* W7 b2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org  {0 a* g* F2 N# O& I+ @5 A

- C# x% B  `. R5 }9 N3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
4 F2 L% L" W# w% L————————————————/ F9 B% h( T9 {% G8 C3 \
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
5 L, b6 `( R% @) _4 M" M5 i; p/ T" b原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

319

主题

485

回帖

3133

积分

管理员

积分
3133
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7" c% L* Y! H$ l  `* j7 s! b

9 G0 M) a- S, b$ }+ e( ~; s由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
( I% F# j, J2 s# h- G# `
' s1 x# Q" R) S. ^4 O# w然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!7 ~- }0 e+ ~, K+ e% b! C% d3 j
————————————————: K+ ^5 J2 V: p4 h7 \
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
# s' S4 I9 |+ C- {( i7 ]" w原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-23 14:47 , Processed in 0.082949 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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