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

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

[复制链接]

341

主题

540

回帖

3565

积分

管理员

积分
3565
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
7 e% b2 j% O6 l- N. }/ g
```bash6 ~# C! ~8 a  T7 c. {0 K0 Q9 r
gyp ERR! find VS
6 A' e8 g+ W) \: N7 `1 y% ?. xgyp ERR! find VS msvs_version not set from command line or npm config( d/ o8 A4 k" H3 a; I6 z- o; w4 O2 U
gyp ERR! find VS running in VS Command Prompt, installation path is:
! I, o9 q2 K% y3 o- Fgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
0 f2 k( `! @$ t  _) g2 G4 w0 l5 p1 `2 fgyp ERR! find VS - will only use this version# ^5 J" g% Z. m
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
3 F3 C+ h% i, c% U0 D6 w; agyp ERR! find VS looking for Visual Studio 20150 ], j  `4 e3 b, G9 O4 r0 _
gyp ERR! find VS - not found
5 k4 m3 M9 H: q# Q% l3 V/ E: w; {7 pgyp ERR! find VS looking for Visual Studio 2013
7 U, `% f: ~- K4 H- l. S' dgyp ERR! find VS - not found
* q9 q  i/ H. j! K; O: Lgyp ERR! find VS
# R3 y" l3 m9 A  egyp ERR! find VS **************************************************************
+ R6 t: L. d/ Xgyp ERR! find VS You need to install the latest version of Visual Studio
7 O( D8 \' B4 U3 ~gyp ERR! find VS including the "Desktop development with C++" workload.
+ y4 [# \, E0 b' s- ]gyp ERR! find VS For more information consult the documentation at:0 P7 m% ]7 c9 N. z" k2 N
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
. A8 v/ s7 m3 ?8 I4 ^gyp ERR! find VS **************************************************************
2 y) q6 p$ q4 {2 W' S% z' V! Tgyp ERR! find VS# e9 N5 _2 E2 h& [2 F% L& j
gyp ERR! configure error
2 G, h  f" E, o# g" N( K7 [gyp ERR! stack Error: Could not find any Visual Studio installation to use8 `6 T5 X# S: W* l0 r3 I5 q
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
8 g  \8 N- E/ y& B- adio.js:121:47)
; d  n* R$ m# o! \6 }# A6 ^4 ?gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16) g& U! ^# H' j8 r
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16! U! h0 x7 ~' ~* P
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7; E- `* d4 ~8 f1 a
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
# I3 X0 {+ I8 P) R- t) {gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)& F2 H# Q/ l; F+ R
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)2 I1 E) t) T$ j0 {' Y' L
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)6 V( ], I/ E0 T0 O. _, L
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)& b1 w4 q( Z2 \( C% O( M+ w
gyp ERR! System Windows_NT 10.0.15063
% ^5 N( T# d  e+ F4 u7 [* J1 y
% E7 y& S# [6 ~5 r7 X
解决办法
+ y9 H" C& ~1 O4 l1、卸载nodejs重新安装一遍. W: J6 \. i( S
- R' W7 O: o5 p
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org% }! U4 X) j: u" O

( d' L6 v: M; y& y$ h3 ]' F3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools1 N# r0 x8 a& W3 m. J7 Y+ k# Z
————————————————
# Q& U( G1 b: s: W  E, L' ~版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。6 H8 K" t1 ?- o) \/ Y
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

341

主题

540

回帖

3565

积分

管理员

积分
3565
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
  t6 D. g3 _2 ^8 [! l7 [) X" Q# S3 x; {
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
! V- k. d, V8 r/ p0 K0 R2 x* G+ ^+ j5 B; q; t, Y3 N! e' o
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!& A* L, z" d$ S1 O6 H1 |% K  s: I
————————————————7 m. r  K* I0 S3 [- {7 E/ q( o
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
( M8 R/ v2 n$ P, {& H9 ?原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-24 06:20 , Processed in 0.012697 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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