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

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

[复制链接]

340

主题

522

回帖

3494

积分

管理员

积分
3494
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
2 r& a9 E( R( r4 Z5 ]
```bash# v4 f% s2 L7 ]8 K
gyp ERR! find VS! S& s% K0 p! L2 V4 u6 N
gyp ERR! find VS msvs_version not set from command line or npm config, _6 n2 U6 B$ g* ]& ~- {2 g
gyp ERR! find VS running in VS Command Prompt, installation path is:0 {1 n6 l# T' S' k3 w& n) B/ t
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"2 v* T6 e% H6 ]5 ^
gyp ERR! find VS - will only use this version
& `( G$ Y. t  i/ C% g' ~4 Kgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
8 e2 M* S) `5 X" D8 l" E' h: Lgyp ERR! find VS looking for Visual Studio 2015; i7 q# }) r6 o
gyp ERR! find VS - not found
" k6 M8 f& P! o: D; H( ^gyp ERR! find VS looking for Visual Studio 2013- A) @9 F* w& y6 U
gyp ERR! find VS - not found4 ~* X0 w3 Q! j, G7 q: ^
gyp ERR! find VS4 b& U4 q1 m+ f. i$ G
gyp ERR! find VS **************************************************************
2 Q# ]4 J" t" Jgyp ERR! find VS You need to install the latest version of Visual Studio
* v0 Y) t2 q) f$ V" X+ O! Agyp ERR! find VS including the "Desktop development with C++" workload.
7 S) U4 J; E: jgyp ERR! find VS For more information consult the documentation at:3 i) v8 y( A5 t  o$ T; n
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
: l3 {  P2 ?% Xgyp ERR! find VS **************************************************************
2 r2 j5 X8 E! Q3 J% J- X# F$ Igyp ERR! find VS+ r0 ^8 C3 T; S: G+ S/ ~0 z
gyp ERR! configure error3 A( L) o* |+ y; s5 L/ y6 S, f( I
gyp ERR! stack Error: Could not find any Visual Studio installation to use
' d2 r$ H5 m( S1 q) |gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu+ h9 j4 P6 @0 @, T6 b2 K" {
dio.js:121:47). u2 U4 H  Y/ p9 o- [
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:169 @" J7 {8 @$ i2 x" C. S& q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
* L- m; b+ @( ~+ g0 e" ]! Ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:74 f5 h, B# T/ g5 U6 H2 {
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
8 |! x5 e- Y- w$ Y* J  _gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)7 R. J$ f# j2 ~, W" M2 ~
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
% z: M7 r. s& w  d, S0 \4 \gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)5 O2 q/ p& m  F9 Z0 ]7 I
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)9 ^6 q" W; X, l7 m* @6 q& |
gyp ERR! System Windows_NT 10.0.15063

* L/ F# l) u1 N  [2 i( L; g6 w' s. E! o, |, D; R& H6 t5 c
解决办法
- v. o( J9 _2 H2 r4 f& E1 g" }% [/ c1、卸载nodejs重新安装一遍; F/ P6 F8 M" y) t7 g. |

( N+ f+ I( S9 ]; D4 r2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org2 G* q3 X! m$ G6 _. s& \, m
# R- c4 y1 y3 |0 z) V
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools+ L4 f) {5 i9 O1 T
————————————————. O! s! M% B/ O
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。: _/ C9 I' C! b% N# B
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

522

回帖

3494

积分

管理员

积分
3494
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.76 R! f8 o5 B$ |
/ p8 @& B1 V, s" C; Q
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
; r6 t1 [# n$ X2 ^
+ t6 Z: H% R$ r' t( j然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!8 G' i5 J1 J; g7 v9 {9 c9 U
————————————————: \! Y" O4 y4 C( X1 o* c% S
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
" S$ D9 @9 N' V1 a0 }原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-12 02:56 , Processed in 0.024652 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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