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

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

[复制链接]

341

主题

541

回帖

3575

积分

管理员

积分
3575
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:# b5 v! r& y) W$ g+ H4 z
```bash
; }2 V$ `, U; E! D& ^. J4 tgyp ERR! find VS- l& `. @2 _$ }5 t2 p! F: P0 M
gyp ERR! find VS msvs_version not set from command line or npm config
/ k+ F( Z1 A$ y! ~1 G8 n; x: igyp ERR! find VS running in VS Command Prompt, installation path is:7 Q) l3 E* J4 O7 ]5 v  Q2 h
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
6 K5 \0 {1 I1 n) }% a+ m" C" tgyp ERR! find VS - will only use this version) a1 Q7 |7 _1 \9 t/ S  z, I4 q0 l
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer+ B) g5 b4 z( R1 q
gyp ERR! find VS looking for Visual Studio 2015' P2 G7 ?& g  N2 y; }' V
gyp ERR! find VS - not found9 D9 e, j! ?: h7 U4 |$ F. T6 B
gyp ERR! find VS looking for Visual Studio 2013) |- }% |/ {2 \9 j  F
gyp ERR! find VS - not found
& W- a# r* }1 Cgyp ERR! find VS
2 f' t. F" o6 X' K& a- Bgyp ERR! find VS **************************************************************, A: r0 ~. [1 ?; V9 D$ ?
gyp ERR! find VS You need to install the latest version of Visual Studio6 c- w$ q; d- D6 c3 u8 l* i( q2 e! W
gyp ERR! find VS including the "Desktop development with C++" workload.& s4 e7 i! Y5 n
gyp ERR! find VS For more information consult the documentation at:
; p  }  M. d7 Z$ kgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows% |* s# f5 Q9 a0 U. y8 G1 s
gyp ERR! find VS **************************************************************; |( h1 r5 z8 v9 c
gyp ERR! find VS8 P" p8 S- q8 q0 A
gyp ERR! configure error
" }$ v, E" J5 n9 E; X* bgyp ERR! stack Error: Could not find any Visual Studio installation to use
: i, E7 r- t9 O* F  K+ B! kgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu9 Q# o( O+ Q3 R0 t  ]! ?3 s
dio.js:121:47); {, \- z/ n5 J
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:161 L4 t7 m+ a( Y9 r& U
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
) _4 K( h4 h1 A2 hgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7  Q* [- {! P, c8 }
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:161 B$ A! D( ~' C9 v4 I- ^+ }0 U
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)3 X7 \* d. L" T- m* d. G1 @
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
6 `# M+ h9 W$ l; x! agyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)6 y5 ~; E$ x1 d
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)* F1 {: m1 x) Q
gyp ERR! System Windows_NT 10.0.15063

$ J3 ]4 L6 m, i0 ?! `+ u9 C% _2 K" _8 A: l
解决办法
9 R6 @. P: h0 z! Q/ O1、卸载nodejs重新安装一遍3 j' d$ O5 z0 n- z) F6 _5 W

4 ~- W" @& L) F" i) T2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
" }# E. P6 @% g0 x+ n
% G$ q. @3 Q) P" a9 ]3 }3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools. W8 ^3 ~* N, d) }) ~: d
————————————————( _* E  ]1 T# a! Y4 s4 U
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。; }; T3 S" g; b
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

341

主题

541

回帖

3575

积分

管理员

积分
3575
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7" T4 \$ j8 v9 y4 W4 Z9 Q

0 N, t  X3 J4 K2 y# X, B# R4 p由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
3 }! m9 p# q: C4 w" v) S& X0 Y, p# C- P' Q! z3 b$ v1 ?
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
: |+ o6 ?# O* b————————————————  @4 w; O0 P; f6 R: p5 \
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
* r6 ?0 w- R8 X原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-25 17:24 , Processed in 0.018953 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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