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

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

[复制链接]

347

主题

564

回帖

3679

积分

管理员

积分
3679
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
2 |5 {4 Z7 u) t2 D7 u! m# w
```bash
7 Q6 ?$ A  X5 h! l. I# jgyp ERR! find VS, O! Q/ u" O% Q) n1 F4 A, G
gyp ERR! find VS msvs_version not set from command line or npm config
7 B7 J: S: O- i9 hgyp ERR! find VS running in VS Command Prompt, installation path is:0 v* p& o# y* h  [4 ]% w4 v
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
$ q  C& J- e# o4 dgyp ERR! find VS - will only use this version
2 Z7 T9 _0 [. w! `+ V5 h' Sgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer& ^0 s6 P+ m2 D: e7 z) d6 w
gyp ERR! find VS looking for Visual Studio 2015
1 l/ D; n: n2 R1 U9 L3 S1 i( I+ `7 ygyp ERR! find VS - not found' V3 e9 `; z+ A$ Z
gyp ERR! find VS looking for Visual Studio 2013
4 ~& Z: Q% ]% f( H; O) Lgyp ERR! find VS - not found
5 \1 |  R6 P- F1 I' m1 u; X; s: Ugyp ERR! find VS
; I# r- U# L) P1 B  K+ Jgyp ERR! find VS **************************************************************
6 ?) M2 w, r: |8 e3 D& ?0 Agyp ERR! find VS You need to install the latest version of Visual Studio
7 J$ @- K7 X5 f: G7 Mgyp ERR! find VS including the "Desktop development with C++" workload.7 U9 T8 d: q" _9 L) V
gyp ERR! find VS For more information consult the documentation at:, t+ n) y# S% e; H0 Y" f/ T4 r
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows) r$ L$ y1 G+ V& N& p7 g
gyp ERR! find VS **************************************************************
8 F: M& s5 G  @/ a& ]4 S( K8 Dgyp ERR! find VS( _* k3 D' `1 ]* e
gyp ERR! configure error+ M4 v* G0 s, n, N
gyp ERR! stack Error: Could not find any Visual Studio installation to use5 [. Z5 i" ?6 N* W5 S
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
" B: o! a3 @8 ~dio.js:121:47)
" U/ K7 a, E$ B+ P. Ogyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16& |/ |$ W* k1 M
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
# {  e  x1 ]) \" Vgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7, Y1 P. P* i; D1 ^1 S8 `7 J5 E/ T
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
( V: U+ W+ j8 Lgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)/ @+ @; e$ i( x8 R) G) c! j% c
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
* Y. v' K/ D1 F# P/ [7 d) m9 zgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)/ {/ s5 f8 a2 ]
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)' L- D- R' v& t* C; E4 Q, e! K
gyp ERR! System Windows_NT 10.0.15063

3 {. v1 A* s7 P. Z( B5 E8 c5 i  D5 }! \9 m3 N& {
解决办法
" Q0 q$ L" @  ~- Q1、卸载nodejs重新安装一遍! g# u' V1 W9 r* w

. s8 R" s9 n8 i6 P3 Z) _2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
( G6 W! ~& t' b
( _! v: I0 K: P! o2 `* I3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
9 K. e, J. W4 ?————————————————' J5 D: S, q5 t- L
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。0 J% o+ p! k4 i1 i" E: ~
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

564

回帖

3679

积分

管理员

积分
3679
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.74 K- z9 O1 j! y2 z" k, d% g2 T

' Y) E  p/ b/ e; t1 E! Y由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。3 z, f  C1 [, V8 P

: ?3 C4 m* E- G然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!  b5 W% S) q. P5 k* F& l, U9 A
————————————————
7 H- @' r& b& T- {4 d2 K# q版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。7 O& |: r8 n' ?1 `: X' P/ z
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-10 07:39 , Processed in 0.012769 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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