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

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

[复制链接]

332

主题

512

回帖

3366

积分

管理员

积分
3366
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:# n& ]' q: C* C0 W
```bash( j# p$ {! C" K; U- M
gyp ERR! find VS
% O, m" H* O9 i/ C# v6 Cgyp ERR! find VS msvs_version not set from command line or npm config
/ I4 j# q5 a8 b  D9 Cgyp ERR! find VS running in VS Command Prompt, installation path is:5 ^0 u& {/ h3 w0 X( |, F' ]( P9 a
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
6 q  C4 u* Z+ Y! p. z9 @gyp ERR! find VS - will only use this version8 a, m7 A$ L# |. K
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer4 J3 `8 ^1 Z3 Y5 p2 Z8 O
gyp ERR! find VS looking for Visual Studio 2015* g5 C4 l$ h) J, y
gyp ERR! find VS - not found2 U. l# S6 b1 a; o
gyp ERR! find VS looking for Visual Studio 2013
& B5 G6 A8 {' E" r0 R* l+ Pgyp ERR! find VS - not found! n$ O( Y. k  {) L
gyp ERR! find VS
- B& ~( J) S' U- }/ x) K& Agyp ERR! find VS **************************************************************
( Z+ p/ k4 _% W" z4 ^  j; xgyp ERR! find VS You need to install the latest version of Visual Studio
$ c. b0 f* E7 c5 a. Zgyp ERR! find VS including the "Desktop development with C++" workload.
+ _, I1 O' A, ?+ V, Hgyp ERR! find VS For more information consult the documentation at:% o0 V7 M) i5 W% E( n9 P
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
2 M: f8 _+ _3 O" u9 D% D: ?; c; Ogyp ERR! find VS **************************************************************
2 C1 N0 j6 a) y2 kgyp ERR! find VS
" ~0 ?& o9 a4 v4 d% T5 I0 C3 Kgyp ERR! configure error
% V8 M3 ?# v) n+ e6 Igyp ERR! stack Error: Could not find any Visual Studio installation to use
# S/ J! \* z3 ~" Tgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu7 M" ?0 Q$ y8 Y! c) B7 a
dio.js:121:47)
$ n: b2 B$ e' pgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16) A9 |, D# J0 `* v' y, ^( R3 l
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:161 ?& ^* D% Y8 P2 r! o( A% }. U3 R
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:71 d; F/ D; z: w+ J2 V: `
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16, g- U1 s  b& G
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5), K: ?9 u- }7 r, C- C
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
" ~) y8 y0 e6 igyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)8 ~- [5 d" D$ I/ J& ^* c
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
9 u& C0 H5 F9 H0 h: Pgyp ERR! System Windows_NT 10.0.15063

. F' Q% X: f! g/ A: ?0 Q5 Z# h2 H7 k* b) }
解决办法
: D/ R( N+ W1 w) s3 r* }/ u1、卸载nodejs重新安装一遍
3 w  z( o; k! z8 E2 b" ]6 L' G+ _. y2 N3 I
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
0 c. r0 ~7 V. z2 h2 j, L6 T' m: F9 P1 J! I" M  ^( E
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools& [! C6 O% G, M" A& T" @
————————————————. d; w& W$ n+ D4 ^6 t
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
* M) u' C; k. B- R# ]  B原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

332

主题

512

回帖

3366

积分

管理员

积分
3366
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
" N( {9 M! G  u4 y4 p, x9 w+ l1 a9 Z; V
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。2 O: m( g* G+ X, k7 O( }+ ^7 e6 `

& e! e3 ]& O# z3 j. ~( l* x9 s然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
5 ^' [5 h2 j" a3 }0 n3 i) u5 N————————————————
1 x9 [# A* w  u, F版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
8 V& i! Q" a8 T( H0 y原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|通达产控投资 ( 粤ICP备2023021749号-1|粤公网安备 44030402006137号 )

GMT+8, 2025-11-22 17:31 , Processed in 0.071484 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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