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

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

[复制链接]

338

主题

521

回帖

3478

积分

管理员

积分
3478
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:3 a! v; y$ Q5 ^3 a3 v* n
```bash
9 p) i# o' J7 a3 j$ I2 Ggyp ERR! find VS
9 q, @, `/ {  t; S- F* Y  u6 igyp ERR! find VS msvs_version not set from command line or npm config
) ?. x( H. m- N- N" {1 c8 pgyp ERR! find VS running in VS Command Prompt, installation path is:
( k7 V: [6 p( I3 Qgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"5 b/ G! b" E7 [; G& S
gyp ERR! find VS - will only use this version8 |; b: ?$ s. M+ y5 |1 S
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
5 x8 B. p! [7 l3 m7 K: hgyp ERR! find VS looking for Visual Studio 2015. m' ]7 J: I8 {2 A! |" I$ S5 G0 Z
gyp ERR! find VS - not found
4 _, s1 m3 F* d. g6 agyp ERR! find VS looking for Visual Studio 2013) G  A( T# J6 L/ s' o; B
gyp ERR! find VS - not found  B" g" O; O0 H9 P4 N
gyp ERR! find VS& Z9 V" B# U! q* X
gyp ERR! find VS **************************************************************$ G. b' E& a" @" x$ j
gyp ERR! find VS You need to install the latest version of Visual Studio- G' T& M6 Z5 u$ Y# O
gyp ERR! find VS including the "Desktop development with C++" workload.7 a. u- W" F/ _* h+ `+ h2 q9 a
gyp ERR! find VS For more information consult the documentation at:- Q  e4 b. E7 u* a3 N" G  x2 g9 j
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
* }9 a' M5 ]( c) Ugyp ERR! find VS **************************************************************
  a* J, e) c) z  i5 Y4 \% M! P$ kgyp ERR! find VS+ m" N3 w% \" S; @6 d
gyp ERR! configure error
# K5 \4 K# |8 l3 n& T3 [7 v' C: Zgyp ERR! stack Error: Could not find any Visual Studio installation to use1 h  H+ o4 A  x: u$ }4 m# o
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
0 N5 R$ y5 U) A9 h1 z% Z# xdio.js:121:47)& a$ `2 s, I+ F6 v6 \( }
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
; ~# Z' @8 t5 O2 [. B9 t* P  |gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
7 n( g9 g: _# [; D  k4 Y2 hgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
; q9 C' T# v2 c7 l, xgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
9 ^8 l+ U$ {% c4 ]) p9 hgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)- R7 B* D; q* n; N; t& f
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)2 D# s$ u9 a# S+ p
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)5 ^% X! u3 P1 L, b; d0 Z
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
! P5 E! {0 h" B; i! G# {8 Cgyp ERR! System Windows_NT 10.0.15063

: N$ V% N) r2 j! @, S' q. z1 Q
" H. V' E% E; w. c解决办法. ~( K9 ^/ {5 b& p( W) Z+ {+ l
1、卸载nodejs重新安装一遍
8 R' h4 H1 i% l  c9 g1 l" l1 b% m5 W) |
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
0 G" r) j5 L7 X) |% i0 v) {5 a! S2 Z4 E' j6 h: c1 T) E
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
( D- G: e+ H+ [————————————————9 R: b1 C. O" D3 {  ^7 ?# r
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
! ], V2 X9 N/ ^$ o原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

521

回帖

3478

积分

管理员

积分
3478
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7; q8 f8 Q' ?7 C* v5 q$ u
- }2 e( o8 w9 q7 q
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。8 L2 h3 v+ s; S' l. T/ B

; h4 E' n6 \  H# d7 q9 B然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
3 N1 S& r# J; D4 z————————————————
& I! Y! o" y% V8 [+ y; D版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
2 V. a1 a7 P8 V  E) P" t! g* ?原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-9 00:15 , Processed in 0.019516 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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