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

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

[复制链接]

347

主题

565

回帖

3683

积分

管理员

积分
3683
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:) }/ j" x& z7 W/ y1 q
```bash" [; e6 r6 \3 p( w/ U" y! n$ I
gyp ERR! find VS! ~# v6 b, ?' w; o* a/ P6 x
gyp ERR! find VS msvs_version not set from command line or npm config9 u! ?4 Z$ d! \" i8 v
gyp ERR! find VS running in VS Command Prompt, installation path is:
% O" ^" d$ y) c" \1 I8 X& bgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"/ d9 W, U0 v, H# u3 u! X- I
gyp ERR! find VS - will only use this version
! o2 d* _3 J/ ^" t, Z; |gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer8 m8 j8 t4 ~. z+ i% b+ S% {
gyp ERR! find VS looking for Visual Studio 2015
6 M; D) C) m+ \* g8 U% ggyp ERR! find VS - not found
$ f6 R- \% a5 X2 s. ?/ }gyp ERR! find VS looking for Visual Studio 20132 N+ V+ j+ Q2 L3 x/ ?
gyp ERR! find VS - not found
4 q$ `. L& Q$ O. q; Wgyp ERR! find VS) r" Y' {# x, S7 @6 J, P
gyp ERR! find VS **************************************************************
; k/ e6 q+ L0 l9 T9 Ygyp ERR! find VS You need to install the latest version of Visual Studio; E) \3 B4 U  I1 P
gyp ERR! find VS including the "Desktop development with C++" workload.8 P1 ?  G9 \1 {' C
gyp ERR! find VS For more information consult the documentation at:& w/ z$ D- ^6 w# y) E: K
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
% w3 U% r+ t; Q1 `gyp ERR! find VS **************************************************************/ E/ Z7 x5 A, s: u
gyp ERR! find VS, H9 Z2 W4 i& A3 ]
gyp ERR! configure error
" J2 z/ s  Q: z4 q) Wgyp ERR! stack Error: Could not find any Visual Studio installation to use
9 K7 X0 F; D/ S* b  a9 ogyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu( v4 n; S* B! K0 L. c# l
dio.js:121:47)5 R  X; {: {1 E) A2 T
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:162 E! n; |5 V8 P4 B( p0 s2 u/ T6 K
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16- n9 O; C1 q% \/ m: J3 ^
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7- {8 ~6 ?/ ?: E3 l8 d7 p9 Z
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
5 t- P. k& I6 G2 ~: C8 Dgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
) R% m3 q! Y  t' W/ xgyp ERR! stack     at ChildProcess.emit (events.js:315:20): g& m- p7 n0 ?
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)* K1 Q, N  b5 y% Q: z8 N. [5 |& T( f
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
% m* _" x7 b! R% D4 bgyp ERR! System Windows_NT 10.0.15063

) n$ @, v1 Z2 M8 S
7 q+ A7 V1 u8 h/ a解决办法
9 ?8 {& z0 b) h) u5 `1、卸载nodejs重新安装一遍) g6 e8 ~; l4 H
% b0 E4 j3 s- l
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org2 d+ x4 ~, M' G% D, |
/ p& |( X. {0 _1 u" E6 f
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools7 b% ?2 U7 q+ }- p) v! Q
————————————————% Q2 K# `- }, B' ?0 G1 t+ F
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。8 }- G1 \% m' P5 I- ]3 J8 i
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

565

回帖

3683

积分

管理员

积分
3683
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7. T1 L# [; W5 c" j' @( m
& l- T$ J* g& q) U0 ]+ G
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
7 A9 Q5 C1 k1 d) {. Q4 O2 J3 z1 q3 z2 R$ |& ^  o- I
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!5 }$ Q: w$ P/ o5 \" z' t& ~& x
————————————————" s. g' j6 V( P6 b1 s1 a9 ^5 G5 s+ \
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。' f+ Y" J$ P7 i5 I" x% u
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-11 09:53 , Processed in 0.012718 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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