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

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

[复制链接]

338

主题

521

回帖

3478

积分

管理员

积分
3478
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:) F. l- Z; _3 z. r
```bash$ H* T# l1 s$ j( R0 z
gyp ERR! find VS
6 v8 W9 W; H5 ngyp ERR! find VS msvs_version not set from command line or npm config' a& J# v, {6 `
gyp ERR! find VS running in VS Command Prompt, installation path is:& v) A1 E$ q8 W" y
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"' }* Z5 @8 E3 f, r/ f7 r1 A' ~
gyp ERR! find VS - will only use this version
7 V" g+ k6 B5 {' V0 M: i) t$ G3 Ogyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
/ I2 a! }2 ?: r* \# sgyp ERR! find VS looking for Visual Studio 2015( H# ]5 {2 i& s' i0 ]! P
gyp ERR! find VS - not found
3 ], \/ a8 u: h6 agyp ERR! find VS looking for Visual Studio 2013; A( H% }! {" l8 i, L- u
gyp ERR! find VS - not found- s; v* [- P2 n* C% Y
gyp ERR! find VS
, K; T! O7 a9 e5 `8 bgyp ERR! find VS **************************************************************/ C, c8 ]8 W, R5 H  E
gyp ERR! find VS You need to install the latest version of Visual Studio
* J) c% Q9 Q1 R$ s0 g, R  tgyp ERR! find VS including the "Desktop development with C++" workload.% Z2 c2 ~. o0 ?8 _) y
gyp ERR! find VS For more information consult the documentation at:
8 n% @3 k+ X* g9 Mgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows* `) a2 q; \- _$ A9 L
gyp ERR! find VS **************************************************************/ ?; ^5 @- c/ q) r/ g4 M
gyp ERR! find VS9 I% g$ N. {% _2 q0 s
gyp ERR! configure error7 F9 v1 S/ F* W, E, b3 @# V4 h
gyp ERR! stack Error: Could not find any Visual Studio installation to use2 b4 c0 b, |. I0 e+ J; O8 `+ O
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu8 E% u- \$ S# `4 T. m& a$ ~, T. N
dio.js:121:47)$ A& Z. ~2 l" U5 q% g' l
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:161 B) Q0 Q$ z. f0 L9 r4 ~
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
1 f; g6 }' d2 U. Ogyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7' o7 ^8 h# f8 i1 s2 K
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16& D7 H* Z+ H8 j* x' u2 u' e) {
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
5 x  O9 T* A- |5 V, t! Egyp ERR! stack     at ChildProcess.emit (events.js:315:20)
+ g% h. o$ Y6 f( b  F8 l+ \gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
- |( @6 F6 U2 ~: t  @gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)9 V4 T4 ]4 o8 r; u6 h
gyp ERR! System Windows_NT 10.0.15063
9 R/ {/ M# X( g$ t; @% J+ R

4 g# w  U1 x4 Z1 E; T) t' a解决办法- U* _6 w/ l' H# p
1、卸载nodejs重新安装一遍, v: N) C* @" O
9 {) q2 s/ T$ M- N
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org4 H$ H! _, E8 K3 [$ E

: j3 G# t* Q) t+ p- a4 Q3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
# C; Q2 L: f6 C; i: ^& U: o————————————————
; Y7 A. g( `4 R; o; |. s2 l版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。( @7 y0 ^# I. ?- N2 d% \
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

521

回帖

3478

积分

管理员

积分
3478
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
& f! H% P  S, P- F1 G/ u6 O) S( |  D! }: a& v1 Q" m
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
5 m/ w( ?7 S3 Q9 D3 a( ~& l: g$ W' D( y- l2 m) b# P1 c
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
5 h+ J2 N; T5 Q8 h————————————————$ u9 V' z  a3 t& k# t6 |5 ], R
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。0 F/ n- B! m4 g& g3 j8 F  I
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-9 12:52 , Processed in 0.014806 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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