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

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

[复制链接]

347

主题

565

回帖

3689

积分

管理员

积分
3689
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
: }( q) N% t8 {
```bash
% t0 h* _) ]; _+ P! A5 b$ w4 ngyp ERR! find VS
( M$ t1 b  g' v. M0 }9 ?! Ygyp ERR! find VS msvs_version not set from command line or npm config2 }% }6 z- f! m! [) L
gyp ERR! find VS running in VS Command Prompt, installation path is:
  @  B4 Z- b3 @- }gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"0 H  S, b* _: R' c  k% T
gyp ERR! find VS - will only use this version
& Y5 \' N- O/ R9 H- h' y, dgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
) q& a& |) v5 L$ R) x& y! kgyp ERR! find VS looking for Visual Studio 20158 u0 ~) z$ S  B7 g, k
gyp ERR! find VS - not found
$ P' f2 W( e* vgyp ERR! find VS looking for Visual Studio 2013
" i) f: v8 m8 h# e+ J/ Fgyp ERR! find VS - not found, ~+ X7 v( k9 c( z
gyp ERR! find VS
6 b1 W, D3 @! U, Z6 b/ f6 lgyp ERR! find VS **************************************************************9 n* g" a0 N5 }" v
gyp ERR! find VS You need to install the latest version of Visual Studio
6 }' x( M, j6 t/ t# ~gyp ERR! find VS including the "Desktop development with C++" workload.
  F: ^5 ]4 ]7 \. z3 @8 Z" @: agyp ERR! find VS For more information consult the documentation at:+ Y2 _' b3 w( u5 \
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
  L3 M+ ~7 [$ W$ m- ]+ H) s% @gyp ERR! find VS **************************************************************
$ p8 @1 V+ ?' u2 m% hgyp ERR! find VS
8 Q+ H4 M- g' {/ q# Bgyp ERR! configure error
/ X3 _; h2 H$ f6 Q# g" Qgyp ERR! stack Error: Could not find any Visual Studio installation to use4 b" s! r2 g# a
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
6 X4 J2 |5 o" X$ I. A- qdio.js:121:47)
1 O5 ~) Q2 P' H6 G: Egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16( j6 r2 d8 i/ m) E. J1 E' N3 P
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
# S5 [& j9 Q) w/ u) {4 ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
1 Y1 Q1 q' w/ W7 c* {5 ogyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:168 b6 P2 v: A  I* k' C
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
- O" x2 C3 L+ o* y, V! |; a5 l: mgyp ERR! stack     at ChildProcess.emit (events.js:315:20)" S% w. _5 Y  g+ g1 k6 `, j. u
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)% p( c( A8 p6 i2 f' i
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
  @" W+ ]0 e, Wgyp ERR! System Windows_NT 10.0.15063
1 ]( C* S: ^. D% b8 X) d

4 T; l2 ~8 F* q0 |8 O/ j' `( X" o解决办法0 f, i$ n4 L4 g  u- o
1、卸载nodejs重新安装一遍9 H3 F  J: A4 |' I, ^; F
6 l3 J( ~9 @7 |$ V; c
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
1 B0 o; e; ]' J8 c- E& R3 e# _5 P1 y. C
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
# n/ n1 s2 m2 x- r————————————————
, w/ X' w9 k6 N/ V. A6 q版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
& U* C' X8 g# a原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

565

回帖

3689

积分

管理员

积分
3689
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
' f1 {2 a! L7 o5 \9 T1 a. H0 [& C4 K7 Y4 h
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
8 v; u% {4 d" x. |! {1 n, [% L, L6 \8 G6 s1 K
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!6 I$ W- R3 j9 P) x$ P
————————————————' k$ Y1 c& `: I4 X# J& B0 \/ b
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。6 ]' J& h+ E$ i% P/ Z) P* X4 j1 e
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-23 06:28 , Processed in 0.011660 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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