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

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

[复制链接]

320

主题

485

回帖

3140

积分

管理员

积分
3140
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:6 i! y% g& F* \# r* c
```bash
9 F; m* d% z% e. P- wgyp ERR! find VS8 W! U: b& @- ]4 s, G0 F" {7 V
gyp ERR! find VS msvs_version not set from command line or npm config, d4 A. f. t/ q  O2 [
gyp ERR! find VS running in VS Command Prompt, installation path is:& |2 e) Y! Q( }! E0 V
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
+ k  e, h1 p7 U% zgyp ERR! find VS - will only use this version" Y) i; z$ B! @; F
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer  i+ e; T( U2 o9 l! ^* w5 x
gyp ERR! find VS looking for Visual Studio 2015- C5 x4 k7 h, P3 ^7 f
gyp ERR! find VS - not found
: j6 b# d8 O1 B4 v2 T- ]# t* b0 rgyp ERR! find VS looking for Visual Studio 2013! Y& C  ~6 ?' ~+ @# d  X
gyp ERR! find VS - not found
3 i- B2 n; N* Agyp ERR! find VS
! T& \- n' G: O" M* ^0 Z4 A5 r% Ugyp ERR! find VS **************************************************************
+ g1 W7 ^! X- ^/ N3 ]7 r; Tgyp ERR! find VS You need to install the latest version of Visual Studio
) B  F' c+ _. M: |2 M  F# o2 F! Pgyp ERR! find VS including the "Desktop development with C++" workload.
' a! m' D8 H* M. c) o3 h! ugyp ERR! find VS For more information consult the documentation at:+ I# x- N% \- n) ?3 o4 \
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows. M( N5 F" f0 n! u; b
gyp ERR! find VS **************************************************************
" f  r3 H  V4 A6 v+ D# Ogyp ERR! find VS
6 ~) j1 J; J0 S3 `2 c5 xgyp ERR! configure error/ B& K1 ^% `' h& S' A
gyp ERR! stack Error: Could not find any Visual Studio installation to use
# ]6 S/ ?" @$ b( O2 ~( v# lgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
  |( y6 a3 A: e9 Bdio.js:121:47)) n9 g7 i; \/ R5 ~$ w/ [- w
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16% E1 `$ J# b$ |
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16& c* x' {/ E* D7 W, @$ b6 T4 m3 S* i
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7, p6 P  m' x* o# t! k3 r" O0 e
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
' u  M& V$ ?( dgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
; g# r8 R  t0 Hgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
: l- k6 p, G3 r* g: q, [' y: Lgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)8 T8 B; @- `# M) V9 I, M0 m
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)' j8 H( L6 f9 |& W0 z# T- f" Y! a
gyp ERR! System Windows_NT 10.0.15063

, U: W- _; m6 ]: I" }' P) a* b0 z" p
解决办法0 |; h$ A' n' K+ x# R1 _  x+ I
1、卸载nodejs重新安装一遍/ o! k$ C  t% A& A; c% O. Z

  h3 J7 j; j8 x: T1 }2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org  y# I9 P+ i' s- v7 A6 Z

8 l) G0 o2 h5 T2 ]6 R6 R6 \; L3 Y3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
) |) O! G$ m2 X) Q6 |% a- `( [: N————————————————' j" w: j" l5 g
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
+ t& W, K1 ?; a原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

320

主题

485

回帖

3140

积分

管理员

积分
3140
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7- e$ E8 C& g/ r; N1 g, J

& A; f5 \% P/ k& A: D3 k+ \1 v由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。5 |4 r4 T9 T2 P" |6 I2 O  Y# a, o

7 ~! S4 f% P8 V, P然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
! @& N; {2 }" z————————————————
% Y2 M7 u& y) U. `' G' B) Z+ k版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
4 E# D+ o6 g- \. }- J% A原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|通达产控投资 ( 粤ICP备2023021749号-1|粤公网安备 44030402006137号 )

GMT+8, 2025-8-19 13:44 , Processed in 0.077194 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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