找回密码
 立即注册
查看: 1133|回复: 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 | 显示全部楼层 |阅读模式
报错信息:5 U  n2 p' G+ e) h2 [6 s: H3 o
```bash* O+ \  y0 {0 t. j
gyp ERR! find VS  r* E) f# ~: F  B* b
gyp ERR! find VS msvs_version not set from command line or npm config
4 {6 O4 d4 w0 l7 u5 [1 f* U0 mgyp ERR! find VS running in VS Command Prompt, installation path is:
3 m& m' n3 Q: q8 C5 R  m4 cgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"- G7 X5 e1 ?) C  G9 T
gyp ERR! find VS - will only use this version
/ B$ f5 q) v/ L7 {# dgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
# ~% U- o! \6 \" N% s! u8 lgyp ERR! find VS looking for Visual Studio 2015
$ `- m& G1 s3 O$ H! Q( v1 ngyp ERR! find VS - not found
6 q! g6 e, ~* G5 M9 I, Egyp ERR! find VS looking for Visual Studio 2013
4 k0 c0 a  ^! ?; h2 zgyp ERR! find VS - not found
; M$ @( S' T0 h, G) {gyp ERR! find VS
9 [. G7 p0 k7 s* p! @gyp ERR! find VS **************************************************************0 Y- R9 ^3 d9 Q2 W
gyp ERR! find VS You need to install the latest version of Visual Studio
! W  c) K- K" r" i5 \8 Ygyp ERR! find VS including the "Desktop development with C++" workload.
, ]7 X2 z2 w  \+ T- B+ m4 Pgyp ERR! find VS For more information consult the documentation at:% m" n) v8 W* K
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows9 t; t/ L' N3 d9 l7 q) A6 G6 i
gyp ERR! find VS **************************************************************( y/ C- S* @* K: S
gyp ERR! find VS
% i* j; A6 M" q! x" g, ogyp ERR! configure error- {/ z' @. q/ v
gyp ERR! stack Error: Could not find any Visual Studio installation to use
( }& Z+ o# ]/ ]gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu$ C% u2 B# o9 g/ M0 a' E
dio.js:121:47)2 S# ?4 }* m* ^# A$ ~
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16: Q: _8 ]7 _! h- L+ W
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
; D( [$ t7 E- T; C: C/ N* W" Ogyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:72 n+ \, g0 R; \; Z! _5 Z0 F
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16  N# c- F. i1 h( R+ X) V+ N2 B
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)& @* M; W; g1 w' X4 i. x
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)* @% \1 L: V$ s
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
7 d! F& R: {# _7 F" X( W8 Agyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)& D  n. T9 P8 }( B
gyp ERR! System Windows_NT 10.0.15063
5 t5 t' L# T+ _' o* |9 [! W& l

+ I) ~! p3 e" `# a  y) u解决办法- `( e, k# P$ P  E1 J5 G- j$ x
1、卸载nodejs重新安装一遍& ^% _- H1 F9 O

: `) g9 T- s$ O4 _2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org0 q5 P8 e0 B: f
% e0 q# E4 [7 S
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
0 ?4 T7 W  Q/ S" T————————————————
) z6 B! a7 t: b* H! Q2 O3 |版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。! j; w  Z+ Z" v/ N) G
原文链接: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: E/ M! a+ E# I7 ?0 L
) B( B7 |3 {1 w: S
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。+ d7 }/ e, P1 A5 f2 u
3 [/ l, T6 k, ^
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!+ u# Y* {1 P, d, f8 {# g. I
————————————————
$ B% c) x9 ?; [! D* w9 P版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。1 u3 [( Y9 W% n8 x9 m- w6 Q5 m) z
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-22 23:28 , Processed in 0.012872 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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