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

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

[复制链接]

342

主题

546

回帖

3598

积分

管理员

积分
3598
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:; V0 W1 _9 |9 }* F
```bash
. k; o) N6 \; v6 d' B% qgyp ERR! find VS
8 C  R6 P; I4 M! [gyp ERR! find VS msvs_version not set from command line or npm config( R$ ^+ a4 R* j! A% K
gyp ERR! find VS running in VS Command Prompt, installation path is:
4 m5 s& e9 P+ j9 |gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
9 V/ K; O; k1 T% Ugyp ERR! find VS - will only use this version
% F* f, o7 s; U. U7 }: ~gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
, u, f% a; {1 \9 k, I1 `gyp ERR! find VS looking for Visual Studio 20150 U( d" o3 `8 f* _7 D" i, O0 g
gyp ERR! find VS - not found
1 `, k% q/ n  W! Vgyp ERR! find VS looking for Visual Studio 20139 n6 ?# Y1 P- N: r2 T2 z$ I
gyp ERR! find VS - not found! h0 D3 P# \, _! a! o
gyp ERR! find VS& B. i$ R5 a9 R0 F
gyp ERR! find VS **************************************************************. g# t; f' ?' U* n
gyp ERR! find VS You need to install the latest version of Visual Studio8 \. p: O, E  ]: {2 a/ {
gyp ERR! find VS including the "Desktop development with C++" workload.8 V- P& W) T8 g
gyp ERR! find VS For more information consult the documentation at:
9 {  r6 k* y  m% C/ x; N( Egyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows; ]) ~: w, u! _) G  F" ~0 ]' Q9 A
gyp ERR! find VS **************************************************************; |0 d5 T9 |8 I9 h; C3 M; X1 y
gyp ERR! find VS
5 _$ ?  G/ [9 D" Qgyp ERR! configure error. z2 b  \  L6 X- n; W2 b
gyp ERR! stack Error: Could not find any Visual Studio installation to use' G6 Y5 a8 n/ _" J/ L
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu8 \7 s# `* A; \+ K+ t. x2 ?  d
dio.js:121:47)  E1 [9 ]. N+ P; n; D
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
0 m% B$ w7 F0 {8 N5 u/ Ngyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:165 A/ }! J2 B) H/ f
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7# c/ y2 d1 K/ ]- i, Y
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16! ?9 T* k: R8 i; x2 U, ~, o5 J. t
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)6 Z- o2 K+ i$ w
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)( m0 ~9 w0 ~9 P6 G
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)$ M+ j$ h* t: S$ ~* v  u0 P
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)* \0 r: w* W  X( G  X
gyp ERR! System Windows_NT 10.0.15063
4 N  _2 M2 Y  j

8 l1 j0 n! ~6 }6 O$ M解决办法
+ ]( r  I! r5 l4 g1、卸载nodejs重新安装一遍
& K  j0 R: I; D* u9 H2 ?! A
3 {7 n& W& p8 b  J. _9 g2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
- |# U- J" z3 k, X" S+ f) I3 Y
% X  {$ I& B7 Z) m! w3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
6 C/ S! p/ V7 [2 F6 X, y————————————————) h  g& z/ R9 t* `
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
7 n3 G+ V% c) c原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

342

主题

546

回帖

3598

积分

管理员

积分
3598
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7) r* o" \) ^. \/ g' z8 |
! x4 z8 I4 l4 W
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。8 B# |: p8 b' T- m/ u( w0 x

! h# p2 w- z3 B3 [然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
1 \# ~7 Z& ]  y————————————————( ^1 k- j5 \, B+ L. k2 Z
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
9 r. s/ ?* }) t8 Q$ Y4 ]. ]原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-29 09:38 , Processed in 0.018178 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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