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

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

[复制链接]

340

主题

522

回帖

3498

积分

管理员

积分
3498
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
, U) a' W( I% s6 n1 w) P
```bash* Z. q- o4 n! P3 l' q  `/ |8 `
gyp ERR! find VS2 ?, y, V- M- o4 \
gyp ERR! find VS msvs_version not set from command line or npm config6 C7 \: S; n7 c" k& @2 @; k" j
gyp ERR! find VS running in VS Command Prompt, installation path is:
  A+ a! {8 |! L. U' j% qgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
+ `. c) Q, k8 i# f; H3 L" [- agyp ERR! find VS - will only use this version8 n9 w0 X; [4 P3 B" d& G0 b' R
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer0 s$ p3 m% Z) K3 _  N% U
gyp ERR! find VS looking for Visual Studio 2015  Q4 H3 t9 }9 D- M9 q: a+ E+ y
gyp ERR! find VS - not found
+ a5 f; N8 C# U$ g- Agyp ERR! find VS looking for Visual Studio 2013
! ^* I) I2 k' B5 ?; b7 X3 W$ ?- lgyp ERR! find VS - not found" K5 A% x% P9 i2 [0 Z! x  }
gyp ERR! find VS. c, W* V% H' U: w7 i$ Q7 Y3 P
gyp ERR! find VS **************************************************************8 G" ]8 y) ?, U# O4 g- s" h& ]
gyp ERR! find VS You need to install the latest version of Visual Studio) ~  ], e# X: }# {0 n$ o
gyp ERR! find VS including the "Desktop development with C++" workload.
$ q6 T" ]/ Y3 C% dgyp ERR! find VS For more information consult the documentation at:
, o! o6 R4 d) k4 R0 b) k0 Pgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows, _+ O% Q1 }7 f% T* t
gyp ERR! find VS **************************************************************
# b3 n' b# `' }1 q" h$ a: y/ Fgyp ERR! find VS7 l0 K* {" L' d/ N% b
gyp ERR! configure error
1 L5 t0 [. N4 Z* R- Bgyp ERR! stack Error: Could not find any Visual Studio installation to use. M: P. Z6 S1 v
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu. a: J5 c. H( S. M
dio.js:121:47)" Y9 b( h, n% n4 c2 }: E
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16  C7 f. R' Z- g" f8 j3 ?5 f! I
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
* q" n$ O4 B" W9 j4 x- fgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
9 {+ s; T& u. g: D7 Jgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
. v! L* T; D% p# jgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5); s/ ]+ G0 r. l  W- B# |6 e& \
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
8 C0 J1 x& b# V. Q1 N9 \gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
7 P- F/ K1 m- L+ S2 d' kgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
; O5 H; X. O8 M) ngyp ERR! System Windows_NT 10.0.15063
% i( @# ~) f+ m! M' K$ d) V+ l

( x+ R3 [8 e7 Y2 G: t0 g' ]' R  c解决办法
# ?9 F4 B& s' T1、卸载nodejs重新安装一遍' V/ F) E2 P. c' I( J

5 j& E9 X6 O6 N, r7 O6 L7 e2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
; R4 s# w" Y0 ^( f# v# C4 ~
! n! [; l. l, l7 F5 S3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools; ^# L) T1 w( n6 R& x" @( j) L
————————————————
' s4 i  b- U+ Y/ Z版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
. v& _5 \- e/ v) U6 d原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

522

回帖

3498

积分

管理员

积分
3498
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7. a5 E8 Y2 }3 w9 ~0 u

; P$ V. v$ l: W  @由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。$ K5 G) T# s  M! a: P# N8 w

# b% d4 b0 f( X然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!# B/ w3 M* k: F% z8 ?/ s) n  r" `6 u
————————————————
: h. F" X* E! X4 H0 U! b+ ?7 J版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
; j) o1 E( R8 F# y$ i原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-13 15:03 , Processed in 0.018378 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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