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

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

[复制链接]

335

主题

520

回帖

3437

积分

管理员

积分
3437
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
" l' t: u' X2 i, |$ Y
```bash
/ m) g% x6 v2 C- qgyp ERR! find VS& k2 m& ?, [: Z' {# K
gyp ERR! find VS msvs_version not set from command line or npm config
1 s) R, \' v* K/ C/ X5 [gyp ERR! find VS running in VS Command Prompt, installation path is:! I' C9 S! t6 z# ~2 D0 d- F1 i; f
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
/ f. ]" z! U8 S$ z$ [gyp ERR! find VS - will only use this version
! j9 O9 c+ }3 }4 ]. O( |& u) xgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer2 f  t$ V2 C; V; e
gyp ERR! find VS looking for Visual Studio 2015
" _7 X1 M$ b3 @# Z% E% m& u5 Dgyp ERR! find VS - not found
. j1 F& E8 t. Z) W; U/ {gyp ERR! find VS looking for Visual Studio 2013
, L+ i4 i6 J4 x/ P/ h0 b- U4 Vgyp ERR! find VS - not found2 c/ ^+ ]; E, o% m. Q: e/ D
gyp ERR! find VS/ f4 N0 a; Z, I( \; M. {+ b
gyp ERR! find VS **************************************************************, r' v6 Y% A0 g; ^/ j
gyp ERR! find VS You need to install the latest version of Visual Studio8 E) Q. w' u* |0 Z, @- F: F
gyp ERR! find VS including the "Desktop development with C++" workload.7 F- u5 |" Y% d  e. m
gyp ERR! find VS For more information consult the documentation at:
! k/ G4 H. I0 e6 C) [3 i2 Lgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
4 @& T; b3 F2 d( ?: ^gyp ERR! find VS **************************************************************
3 r. q! b- i+ ^5 L: d; Agyp ERR! find VS) E, B! ~; p, _3 p+ R
gyp ERR! configure error9 b9 x) c6 J- N4 T( E
gyp ERR! stack Error: Could not find any Visual Studio installation to use
, _; I! e- B1 hgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
  [" n' q* T; @9 ldio.js:121:47)+ i  d4 [) j2 v4 K. z
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
/ n/ h: h+ `/ ~" D( x' wgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16# T: i! ?8 @( E# Y# p' E# \0 y
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
$ @  B( `" ]2 F! Dgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16. _4 B8 t- Q0 B
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5): ]* E% u3 ]0 |" I. @6 W
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
" m4 N1 i' ^2 ?) P/ g& a& N8 bgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)3 `! z7 S* {' {+ E& G( X. f2 |) H
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
8 B  L: e9 M/ t, m5 x' ?gyp ERR! System Windows_NT 10.0.15063

* l3 l1 g) c- M
$ d( N3 c# H- v3 T+ W2 ?3 h/ P解决办法
9 s$ E; _  M1 B$ e1 b* z5 @* q' r1、卸载nodejs重新安装一遍
' n$ i4 f" I4 T- p
1 c0 S) z+ y) }9 N1 j; B3 w2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
# x7 F" l: A0 o! f2 {  K, w6 V# o/ q$ U" I9 s3 L
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools/ r# |" z8 I& j# G- }) b- V5 N
————————————————
8 Y: t4 L* _6 D/ ^3 h版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。) ]) a6 X+ U1 o0 u# }: ?+ G
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

335

主题

520

回帖

3437

积分

管理员

积分
3437
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.79 d6 K6 c/ s$ S. ^) D9 [/ U

; [9 ?/ \- f" Q/ E由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
3 Z; X+ B5 N" f- T; v6 ~5 \9 Q' T9 z' P9 q
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
* \( [& R8 w  t2 b  S6 r————————————————
% T2 }9 S- f1 |5 I! r- Y* ]: F6 m版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。! U8 q1 m, `$ V9 U8 {& `$ x( r
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-17 10:43 , Processed in 0.077477 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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