找回密码
 立即注册
查看: 1371|回复: 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 | 显示全部楼层 |阅读模式
报错信息:) g  k0 D% b" c: W
```bash5 d- G  X7 M4 V) ]: u# S+ N" u
gyp ERR! find VS- x: r" O, n2 L/ B/ Z" ]. N. h. O
gyp ERR! find VS msvs_version not set from command line or npm config3 i- K& r: L5 u6 Q0 V
gyp ERR! find VS running in VS Command Prompt, installation path is:
. h6 D% J( }8 i+ t2 i0 d1 hgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
5 J+ u$ w6 s; \  f$ N8 i6 f  H+ Xgyp ERR! find VS - will only use this version
7 A/ _/ x$ s" [& f8 Qgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
( j0 o& r7 Q" p9 k- F3 Tgyp ERR! find VS looking for Visual Studio 2015
( A4 x% P( _7 A0 M' X  ]gyp ERR! find VS - not found
& d' L- D2 C! I+ u+ Kgyp ERR! find VS looking for Visual Studio 2013, ^" e2 X1 m' S/ J2 ~
gyp ERR! find VS - not found$ N+ m, E. {8 T- I: y$ k3 N
gyp ERR! find VS: F/ v3 K: K, X  W- s9 x
gyp ERR! find VS **************************************************************1 N2 J  D7 W8 W# ?* \3 y
gyp ERR! find VS You need to install the latest version of Visual Studio
, K3 u& D3 d1 I7 y$ ]5 l6 rgyp ERR! find VS including the "Desktop development with C++" workload.. J* b: c5 o& l  N
gyp ERR! find VS For more information consult the documentation at:2 l9 P5 s2 a; _2 ^9 s- ^1 g3 t
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows0 C/ X* z+ W( A) v) I8 Q, k7 H; t
gyp ERR! find VS **************************************************************  ]+ W9 i" e+ m3 G* V' S: ?- d
gyp ERR! find VS
5 F( S. V1 Q1 {# s* o' fgyp ERR! configure error. O1 O, n% O6 K6 y+ T, Y
gyp ERR! stack Error: Could not find any Visual Studio installation to use
% d% W1 d' U& Z& j% `gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu, L5 k  n% @  w& Q( |% Q0 m
dio.js:121:47)
  R  s/ r/ Q* w, K6 w& S' \gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16$ C% R4 F  f8 H4 ~
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:161 U; q% f8 B, z. ~2 I
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
- ]1 p5 |, H* C1 W- ~; Agyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16" C* P) I: ^7 c1 c# L( o- Y8 M
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)# x9 i$ M2 Q; @4 e
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
& E  J& D/ z5 m8 T/ qgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)( z; P" C6 r9 y( D' Q0 K
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)/ R0 L' `4 l# y- {6 `
gyp ERR! System Windows_NT 10.0.15063

: o4 K; _/ H0 @! N. H" [; a# `
  L* Y9 a' ^" _! P' a解决办法
; Z8 f- U  c  u* @" r; ~1 C1、卸载nodejs重新安装一遍
4 q: R: o% X+ Z; p
+ W+ m8 C% i' ^) x2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
% c" t" S3 i$ P$ |; @: b* K: }( P. e/ i4 Z
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
% C- A* o  o% e$ e1 Y————————————————5 t1 l! @. \  u* E4 p
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。* q, i; m+ K' M  x  F) _* k
原文链接: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
6 c2 B# j4 D/ F: H$ d3 [6 |/ V- ?4 D" K' D( _2 }, X) W+ g4 ~6 q* V7 x  j
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。3 P2 I! t7 `3 e+ X( L

( d: b. p5 v+ J$ a( P; p. P& L然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
( U9 ]# O, Y, \0 {9 `, O0 T2 v# p————————————————
! }2 C( x3 A) o/ t- @版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。/ l( I+ U, D  a' ~. ~
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-19 17:27 , Processed in 0.020777 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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