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

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

[复制链接]

338

主题

520

回帖

3454

积分

管理员

积分
3454
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
- v, S2 m: b" c
```bash
! J* X6 F3 W# D( W6 A# Qgyp ERR! find VS
. _9 o4 v! o" sgyp ERR! find VS msvs_version not set from command line or npm config
' \# X! K! w5 U- R( {gyp ERR! find VS running in VS Command Prompt, installation path is:
  }4 f6 A3 z& Y' W/ R, Igyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
4 G$ I$ y: _. Y" L9 A1 e* Cgyp ERR! find VS - will only use this version0 M% `2 Y3 S/ m9 d  W+ s
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
3 g: g9 d; y' rgyp ERR! find VS looking for Visual Studio 2015
; Q+ \1 a! y8 |, R: @4 P2 r+ [gyp ERR! find VS - not found! Y: n% p  _+ ]5 `/ n
gyp ERR! find VS looking for Visual Studio 2013: L9 b5 @4 d5 A' J% [
gyp ERR! find VS - not found
% B$ V2 B$ u* p. E! R3 W/ Z4 ]gyp ERR! find VS
4 D9 d: t! V, R8 L8 Y9 ?2 qgyp ERR! find VS **************************************************************
, w: f9 U. k' t( c9 j2 Cgyp ERR! find VS You need to install the latest version of Visual Studio& H0 T! R! i7 ]1 F  Q7 @
gyp ERR! find VS including the "Desktop development with C++" workload.& ?% h7 P3 U6 c# r
gyp ERR! find VS For more information consult the documentation at:. I' I. B2 I2 H+ \# N
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
$ R1 g" p: ?) |+ s( ]gyp ERR! find VS **************************************************************" \) F( R% z+ O" P  X2 M4 K
gyp ERR! find VS
+ b! k* p- c+ q+ [1 hgyp ERR! configure error
" P3 z6 S3 E0 \, O$ x8 [! _& Xgyp ERR! stack Error: Could not find any Visual Studio installation to use
0 B: h" P. [4 r& z  g9 v( ugyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu8 I  C& h$ Q) x' S
dio.js:121:47)
# \; P5 h* F6 t. B0 ?gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
/ U# r5 `& A4 i0 Q7 {/ jgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
# E$ u0 u/ Y! L' M- lgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
9 q' a% E4 Q2 L0 N0 t$ Sgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
+ y* L" v1 h! s: x, J/ {7 C" }5 Xgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
2 T% F( p& D# q1 q. g5 rgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
: G6 H8 Q* |! D  e$ D3 A3 v, e) Ngyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
: ?. H& d: p& r. Qgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
( }8 Z7 ?; A5 w8 b# egyp ERR! System Windows_NT 10.0.15063
8 Z# G3 T4 K# g4 H" O3 U. ^
/ ~% N: t: ^- n2 v. P
解决办法
; ]% X/ l. ^, T& o4 I. J9 f1、卸载nodejs重新安装一遍$ ?5 F: C+ ]6 X( z5 x! ~

* H  b# ?, E% Q2 Q4 U2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org( {5 n5 a* }/ `7 O5 o$ l; b

4 m8 Z7 y( R' `1 w9 ~6 H: n3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools; v( |' p7 R8 p( f2 P7 M7 s
————————————————
) h% c  v; u9 v. k" x2 Y8 l版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。# B, ~$ |( d7 B2 A# l
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

520

回帖

3454

积分

管理员

积分
3454
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7. i9 y# Z2 M4 F) \
  ~6 G* w: u- a! u
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
7 m  U: \7 q. N3 K9 [  h5 U7 W' O- ]" S* B. @
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
9 ~6 |# z' d0 Z1 K- P0 f————————————————. V1 r+ a) h# m% e) [2 ^! n8 `6 e% M
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。6 L. N) ^+ M7 |' I
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-25 04:47 , Processed in 0.023738 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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