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

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

[复制链接]

340

主题

522

回帖

3502

积分

管理员

积分
3502
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
# W# z; c) [( j. O$ ?7 P  o
```bash
. Z# N' K2 `# C( N! ^: m! c/ ngyp ERR! find VS
" D0 Y1 G3 N. Y% C) a0 a; ?% ^gyp ERR! find VS msvs_version not set from command line or npm config$ \8 S% Q, s/ _' O
gyp ERR! find VS running in VS Command Prompt, installation path is:$ P, L$ p8 `1 R4 V( x# K6 S( o6 B
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
. M" z$ o2 D- E: k5 ^7 Zgyp ERR! find VS - will only use this version
2 _1 @; F5 [2 t! ?& ~% Cgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer0 X' s, K2 r9 O0 E# a" v
gyp ERR! find VS looking for Visual Studio 2015
/ R0 i. c0 V% @0 H/ agyp ERR! find VS - not found
8 f0 P! P7 H$ b* Vgyp ERR! find VS looking for Visual Studio 2013
( v+ H$ Z' v+ ~* z4 ]% m, ~8 Agyp ERR! find VS - not found
. _* W8 `5 G$ \. D% Kgyp ERR! find VS
+ g, x8 L- R+ I0 [0 q+ U5 K$ Hgyp ERR! find VS **************************************************************5 h- C: f4 L# A8 q2 T
gyp ERR! find VS You need to install the latest version of Visual Studio8 @; k4 i' B& e, H  d3 G& g
gyp ERR! find VS including the "Desktop development with C++" workload.
, R. f% n3 y, h! Agyp ERR! find VS For more information consult the documentation at:
7 P4 k( i, n, t; W; H0 h' H; k# Dgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
/ p- Y4 a* {4 Zgyp ERR! find VS **************************************************************
# i! [0 g/ ]' c3 O0 B6 xgyp ERR! find VS
  I. v: X1 {  b8 F. @  lgyp ERR! configure error8 u% \% h8 V2 d; l' @/ n
gyp ERR! stack Error: Could not find any Visual Studio installation to use
8 b4 @% {! }+ s" ]  y4 J$ M9 ?' lgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu7 O+ g' ^( |; _$ K6 b
dio.js:121:47)
/ t6 G6 T; F) a+ ]. ]5 ~; x' xgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:169 _. h% n" b( C
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
4 m# L* F: [, n% b) c5 R  ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
5 r6 q- @% t8 t5 Wgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
$ U6 A- T- f3 L: K/ X5 Y, Fgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)! N+ c5 d% o+ [8 Y) S
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
+ ?; n4 v) b$ ugyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)  `+ J. f' ?) w. q* V" F5 r- G& q$ K
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5). W9 q5 k, t5 \& a/ @+ S% M; S
gyp ERR! System Windows_NT 10.0.15063
! M: w0 _9 D9 o

$ `1 O9 {8 A  X! d, \7 P6 ]解决办法
7 [; m9 k1 g8 o6 _* K8 R1 T1、卸载nodejs重新安装一遍
( S! R4 {: b3 `! Y/ J8 r2 Z$ P2 d. l7 F6 ?2 V
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
0 y; x, H2 A" L; o' }: e5 ~0 E* S( r( y: H% q* B3 K0 d  }9 l. l5 [
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools" @' H: Q3 D8 A0 H3 i
————————————————4 n2 G; V/ s# o6 A0 w* y+ C, n
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。- B: g. H  T+ ?4 y5 o/ X
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

522

回帖

3502

积分

管理员

积分
3502
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.79 H5 U) Z% S- r
: ~0 I1 ^$ b: [9 s! [
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。% L. K! C3 V& r3 I1 C! X/ s

- O; b5 g9 o* R/ ^# U6 `; [然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!3 X0 s. q: H. \6 v. v0 b: O" B# x& Q
————————————————! x" v  l5 E2 S2 t, w# v/ I- \# G
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
+ c  N% q: I/ r; O& n5 b! r原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-14 06:19 , Processed in 0.019731 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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