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

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

[复制链接]

334

主题

517

回帖

3396

积分

管理员

积分
3396
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
# E3 y2 f) c* Z+ O, w
```bash/ l1 l& o% W) @1 C$ T
gyp ERR! find VS# y* t% i( f& Q
gyp ERR! find VS msvs_version not set from command line or npm config( ^, X4 L# F1 q9 a
gyp ERR! find VS running in VS Command Prompt, installation path is:
' x% I8 S5 N: l0 Z7 Cgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
+ ~6 Z" j3 {. a; p8 S# ^gyp ERR! find VS - will only use this version- w$ H" X+ m: g* B8 H
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
1 d4 s( t( x8 S+ v$ J' \gyp ERR! find VS looking for Visual Studio 2015
% J* b/ w9 e2 H& t; Ogyp ERR! find VS - not found
7 C* ]# i4 l  a& @$ f% u% jgyp ERR! find VS looking for Visual Studio 2013" F6 ]  i7 H% _: x
gyp ERR! find VS - not found1 r  y# Q* y4 S! X! O
gyp ERR! find VS, t- `& U- s* O: b( [# e1 {
gyp ERR! find VS **************************************************************
# N1 ~$ O8 l) O5 x  o9 @# Wgyp ERR! find VS You need to install the latest version of Visual Studio
2 S3 {$ A. i0 [* \% G% m0 O/ n( Agyp ERR! find VS including the "Desktop development with C++" workload.
/ O4 m/ S' k. g# Y& vgyp ERR! find VS For more information consult the documentation at:
9 f7 l3 W8 q1 C5 ~& J5 Pgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows* @( `! v6 A1 v0 `
gyp ERR! find VS **************************************************************0 W+ ~( m. A  \( u! l
gyp ERR! find VS
3 Q7 m1 u$ h7 c6 Ogyp ERR! configure error
1 l# f* K2 V, j. D; [1 Agyp ERR! stack Error: Could not find any Visual Studio installation to use  J% a+ b3 R$ H
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu/ `( B. T8 P# w& [: @
dio.js:121:47)
0 T. L  _1 A/ H" J) Vgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:160 E6 X7 Q; F. S% E. _) u
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16/ O" }, S3 a2 r2 h
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7! _9 t! M! h* z* Q/ Y# L8 g4 W
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
6 v; M' J0 s8 Bgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
. a# B4 c! s0 q7 C  E( k4 Tgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
( W3 v* \- F# m! |: A% Jgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
5 u6 ?, E6 D3 ?1 q$ Ogyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
6 l7 v- ~" g/ ~+ t" L- Dgyp ERR! System Windows_NT 10.0.15063
3 K( b- a/ I3 m7 H0 J

5 v& W. r- r2 x9 Z# K解决办法; \+ \0 G9 I2 x. U" k$ K3 N/ O) I
1、卸载nodejs重新安装一遍
' Y0 W$ R0 i) S' ?5 U5 M2 r# |  j7 _3 E9 M( c1 t6 f3 A" H
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
" e8 g7 l) h/ b7 |8 |5 h8 `; m+ p; W) a' V4 |) B' S! i! m
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools6 q5 b' h! a! S" Z
————————————————# {4 S/ O- s; I
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。; b9 {" {' o5 p- i( v+ M( Z( U8 |8 v
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

334

主题

517

回帖

3396

积分

管理员

积分
3396
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
9 ?; e3 x8 C; [8 N/ t/ j+ Y+ I. b; N. T9 c
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
5 T0 a; t% Q( R& f; [: ~  u8 `, n: e) f
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
# A" _0 p4 c7 R4 {' S————————————————
: ~# i/ s. r) k$ x9 Y# J版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
+ R" {) M9 U. ]原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-3 01:49 , Processed in 0.067633 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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