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

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

[复制链接]

334

主题

517

回帖

3396

积分

管理员

积分
3396
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
/ [9 z6 M* k6 O4 v& ~  T% P
```bash
! y8 ]) \4 A+ C% ~6 l* T* kgyp ERR! find VS
# x+ Q- h' z  U& K( U" q( D, dgyp ERR! find VS msvs_version not set from command line or npm config0 F: Z6 l8 W0 r. `  |: @0 u8 K4 z1 z
gyp ERR! find VS running in VS Command Prompt, installation path is:( V! c$ D& ~2 q/ E
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
, \* f9 u* s" c7 \gyp ERR! find VS - will only use this version$ R. k$ k* [* N& m1 w, g
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
6 _* x% |: p, \gyp ERR! find VS looking for Visual Studio 20152 B# F" C: X, ]: }8 u
gyp ERR! find VS - not found* c6 \" Q# U) Y" ?6 N
gyp ERR! find VS looking for Visual Studio 20136 S" y+ M/ ]" h+ [
gyp ERR! find VS - not found
7 Y- T' `% v$ m% y; w2 Kgyp ERR! find VS( t* t/ A3 {; S7 H( E$ S1 y: R5 W
gyp ERR! find VS **************************************************************
0 @, ]( c: B$ Tgyp ERR! find VS You need to install the latest version of Visual Studio
9 \) s* h8 g/ r5 ogyp ERR! find VS including the "Desktop development with C++" workload.
  s% t- V2 Q$ |. Zgyp ERR! find VS For more information consult the documentation at:1 H: D/ h: A5 V: @
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
* f# f8 s6 y/ {2 ?gyp ERR! find VS **************************************************************
( r: G% |) w& f7 n$ `2 V. r& ugyp ERR! find VS1 l, L/ D9 N. m( b
gyp ERR! configure error
& O$ p) n3 I1 c1 b* r( g2 {gyp ERR! stack Error: Could not find any Visual Studio installation to use
/ |( R- c0 H6 W+ vgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu9 t# F% @& a; Y
dio.js:121:47)
& ?# n2 r- H1 _- x) z1 q1 M0 ^/ h7 lgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
6 X6 S6 [# C% x$ {' ^0 J4 W- ygyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
' o; B. }$ T" p" N+ Q8 |3 P5 B4 Ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
5 d2 x' \4 a1 k1 u. mgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
: B% Y( k, I5 t& F4 lgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
; y( }1 t/ o# N+ u* q$ [gyp ERR! stack     at ChildProcess.emit (events.js:315:20)( y. J) o% n. J3 X" X  L
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16), m0 b6 R1 _4 P! E% S
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)9 f/ x1 d" \& o: ?
gyp ERR! System Windows_NT 10.0.15063
: B9 K: c4 o' ~1 L
& b( T) n) H4 @$ U; Z
解决办法
+ O4 j* _  c. h" v: c" v4 }2 E1、卸载nodejs重新安装一遍/ \8 y& o( X8 r$ d1 j9 ^: y
3 B% V* p- A. ]  |
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org0 b# t4 i" Z3 }

7 }7 i9 J$ z4 I# Y$ F3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
5 X% s* K0 V4 t4 n. S( ?& T0 D1 R9 j————————————————
6 J7 N$ i, E0 H- u版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。1 d, a4 u" m, A$ B) m* q6 z
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

334

主题

517

回帖

3396

积分

管理员

积分
3396
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.72 J6 U. I5 s( o

# y0 e$ J0 z$ k; N1 B  K由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。$ I3 B3 R) m0 J! B% [1 r
1 D" M0 X/ I2 K9 {! Y$ l( u6 m
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
8 g# y" K- J' K! x% o  S0 \9 s————————————————
- p4 e7 [# o" l3 ^$ ^' G  r版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。- x( b& s1 R5 c7 d$ a! {8 a, y$ x
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-4 08:31 , Processed in 0.067476 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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