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

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

[复制链接]

331

主题

511

回帖

3353

积分

管理员

积分
3353
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
* y& z8 a+ V  ^3 e
```bash  ^# N$ y& h7 g- A# i4 ^
gyp ERR! find VS
+ s& T, C8 B6 a. U) {6 _) c( m% b: k" k9 ~gyp ERR! find VS msvs_version not set from command line or npm config
) M) }. W1 Z; y$ E% A3 y+ Egyp ERR! find VS running in VS Command Prompt, installation path is:2 L2 n6 S3 [9 q2 t
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
) ~1 J. ?8 h. @gyp ERR! find VS - will only use this version
6 I9 {# J( i+ X& z9 Y$ Agyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer& S# z2 P6 u( K! c. E# P# {! D
gyp ERR! find VS looking for Visual Studio 2015$ X! F  F% O! ]( m0 q8 w4 u
gyp ERR! find VS - not found0 }! N" j0 H& l+ I4 E5 @$ [; X) }
gyp ERR! find VS looking for Visual Studio 2013& r) A! C" Z8 V  w5 I5 ~
gyp ERR! find VS - not found  U# i) k. G2 I1 G
gyp ERR! find VS
* E  |7 Y+ B/ E" i" L* B- m# V/ R8 ogyp ERR! find VS **************************************************************' A9 G- @: O& \# c# I& p" N
gyp ERR! find VS You need to install the latest version of Visual Studio
& s* K# j6 F0 C1 T" G" K, ngyp ERR! find VS including the "Desktop development with C++" workload.
! H: k! [) c& `4 y+ N2 r8 Z/ ~gyp ERR! find VS For more information consult the documentation at:/ R" O0 H: o5 O2 z; p
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
; G% J+ `5 W/ a- Lgyp ERR! find VS **************************************************************
& c/ n% @5 {7 D' r3 Hgyp ERR! find VS
" K' a/ u' B% \6 ^$ d5 lgyp ERR! configure error
9 u7 \' w9 K0 S! w8 [% ^gyp ERR! stack Error: Could not find any Visual Studio installation to use
* n: P$ x3 f3 A& i4 @gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
% l; V5 t6 O) c, cdio.js:121:47)* N+ Q; G% f$ a6 b
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16; ], \4 l$ _- v  L, N
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16- {8 B5 ?# [5 v; v+ U0 E
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:70 q# X5 J5 X; F9 h0 Q+ c( A! v9 [1 v
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
+ P; k+ A% }+ agyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
6 E9 ?* |; b' g; h0 |gyp ERR! stack     at ChildProcess.emit (events.js:315:20)% [6 T  f, R; q$ o0 K, E
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
& S3 t+ H8 L+ `6 c4 Dgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
* ?* G7 v' r2 ]. G8 S6 k4 tgyp ERR! System Windows_NT 10.0.15063

0 R, g4 I0 i7 w9 o# N7 ^0 N- f  w( U
解决办法8 B& {+ F. D' B/ l
1、卸载nodejs重新安装一遍
$ ^  v/ Q$ l9 S) y6 `( f( ~& P4 r3 |* X6 K& R
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org- s) h0 F8 M9 W3 y

4 W1 L: h! @, k4 j0 D. ?+ L3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
% @% y* c! S0 s* o+ u5 ?- ~4 M' K————————————————
8 n4 O" `( M5 t4 w版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。* E* z& ]) f8 s
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

331

主题

511

回帖

3353

积分

管理员

积分
3353
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
6 l+ c/ e" g$ P& @- ?# M9 q% e! j6 [. c( v  T  U+ s
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。1 G# T/ e7 I) [- ~) r
6 M9 R7 ~8 X1 Z
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!2 L% k9 g0 M6 u2 _  T4 F
————————————————8 i7 g+ z# f8 S% O3 p
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。  D) B2 l7 W, y, I
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-20 04:54 , Processed in 0.068585 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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