找回密码
 立即注册
查看: 1507|回复: 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 | 显示全部楼层 |阅读模式
报错信息:5 L- l8 H; i  {* [0 I' [, L% \5 g
```bash, c" G+ _; f/ x3 w9 A7 c
gyp ERR! find VS
/ I* x( s1 \* {& Z4 ?4 P6 Lgyp ERR! find VS msvs_version not set from command line or npm config) Z* w- w& N% m5 C
gyp ERR! find VS running in VS Command Prompt, installation path is:4 ~/ C; s9 j" _: U+ P
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
2 K; C/ W! i2 v, O- t. ]gyp ERR! find VS - will only use this version$ v5 d) C0 X2 b
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
" U% g  G" A5 B2 }" egyp ERR! find VS looking for Visual Studio 2015/ ?5 m% s1 a6 F, Q5 ^9 w4 o! ~
gyp ERR! find VS - not found! r& n; t0 H! J' I5 B! ~' E6 A
gyp ERR! find VS looking for Visual Studio 20135 o# ], K' H9 A4 a" U8 N2 H
gyp ERR! find VS - not found
- c5 k1 s+ K9 T. Fgyp ERR! find VS; A' f* r' F9 q# \  P/ M! t
gyp ERR! find VS **************************************************************
$ g, ~, G5 b$ j. u/ P* egyp ERR! find VS You need to install the latest version of Visual Studio, I/ ?& n$ S1 w0 K) A: Y1 B: C  ~
gyp ERR! find VS including the "Desktop development with C++" workload.
" ?* q6 c7 p0 A" U0 Q1 @gyp ERR! find VS For more information consult the documentation at:: n8 K/ b* k. p7 v
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
3 n. m+ v3 ~) ?7 F( c, R7 \( M8 }) ~gyp ERR! find VS **************************************************************1 U6 U8 U. K. b. C; |% U9 k
gyp ERR! find VS
, _! ^: I: o0 C, J% s5 ^gyp ERR! configure error
/ b3 u! p: n8 ]# J1 P' F( ogyp ERR! stack Error: Could not find any Visual Studio installation to use3 E9 l/ L- ]" _7 C
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
* s' v, G1 `5 @+ Kdio.js:121:47)
3 b% C% Z2 j/ ^9 b5 \gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16% N$ f8 o+ _) u* [
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
0 x* s2 O, |) U3 k! cgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
5 w, x! v# `3 P+ d5 m2 Q% agyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:163 V! D; q+ t7 l  s
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5), R) o6 m/ u  t9 a8 ^! Z3 P1 _
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)7 w; ~4 j1 f2 ]9 h7 w  ]
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)/ Y; I; H& I* J( X# a
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)! f2 k0 Z( N+ V# m
gyp ERR! System Windows_NT 10.0.15063
8 \! a* M0 ]1 }( f( ~' N9 Q+ m
4 C6 i( ?0 E$ n
解决办法
) H" u4 V, v- L! I6 c8 n. e1、卸载nodejs重新安装一遍
  }( e) Y# ~# f& [, m& C0 R8 H% M0 ]2 _' H0 R, A; u
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org$ D# e$ `6 o/ s+ Y0 I' Z8 H5 c
) ~7 L  P5 O/ |
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools& ^1 W0 u- F/ G: f7 d0 A
————————————————: n( D  Z( _5 n# y. L$ n% l. ?" G" E
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。$ u3 s  I1 @3 u: |9 D! l2 v
原文链接: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.7- u3 n3 t4 S  |/ \9 B& o
9 _4 ]& E& \& K2 Q. I
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
( g8 u) q( @3 s' U) A( J. B
: |9 a& J9 u) l- A; ?% f4 ]# u然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!! }. H% c/ `) w9 W) v) Q
————————————————( b% w% I- L! l7 m3 G" R
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
) A2 h! c( t! ~/ B2 g原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-10 16:50 , Processed in 0.010035 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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