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

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

[复制链接]

340

主题

529

回帖

3524

积分

管理员

积分
3524
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:* c7 L2 c: y$ }
```bash
7 M* K4 I9 S, V& cgyp ERR! find VS& v* R5 C# G+ q+ X5 G" @
gyp ERR! find VS msvs_version not set from command line or npm config
$ s# T2 T3 e% [& kgyp ERR! find VS running in VS Command Prompt, installation path is:
$ J  [7 h. \* ^; qgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"- c. t) y% O1 q* I. R
gyp ERR! find VS - will only use this version
# w0 C1 `" K  R! i3 S7 D5 p; Fgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer4 Y; O1 F- f& q6 o1 ?+ H) t( n
gyp ERR! find VS looking for Visual Studio 2015
4 D* j7 ]! ?1 _7 w( f6 y( i7 P; Bgyp ERR! find VS - not found& d0 T- n* g  S) E0 s; @
gyp ERR! find VS looking for Visual Studio 2013# i$ F, ?" `0 v6 E
gyp ERR! find VS - not found% D0 s/ d# C9 l. E& |
gyp ERR! find VS
# ^9 A# @# i! @  b2 L% h+ D$ Lgyp ERR! find VS **************************************************************9 x$ X9 f# d" O9 ^
gyp ERR! find VS You need to install the latest version of Visual Studio) ?9 G( k# O, D
gyp ERR! find VS including the "Desktop development with C++" workload.
( F0 n" S) b. _" R; |gyp ERR! find VS For more information consult the documentation at:
5 [& X. I1 D" ^1 ]7 d: X) Mgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
( q6 W( k3 ^$ A2 C/ q+ M0 Bgyp ERR! find VS **************************************************************) @3 i4 a5 |: j4 _4 e
gyp ERR! find VS
5 q! b" A6 b  u5 d9 ^& D. egyp ERR! configure error
$ C) M: _8 S  e* S4 jgyp ERR! stack Error: Could not find any Visual Studio installation to use
. P  T' B, H& z& |  Pgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
# n7 q8 r- [) E$ R; ?& l. d9 d6 Ldio.js:121:47)
+ o& m6 g0 o: E' h" k& }  ~gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
( l2 G! j. `- o- @2 u1 f, R9 U$ n2 ~gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
" J+ x8 ?3 U* B. b5 _: }gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7& Y. Q) U4 ^- a6 y( H
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
0 R% I1 _. X+ Egyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)7 Z8 j3 o$ Q& d- P& C5 f1 R
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
# K: X/ h0 b% ]8 Q/ tgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)+ \6 J2 L. i, Q9 d: y5 \
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
4 T: n. d; Z9 g+ Q5 i4 P' E! k, Ogyp ERR! System Windows_NT 10.0.15063
9 T9 ~7 D3 G; y) g: a$ M

7 I9 ~0 k4 R! w解决办法
1 Z; Q" u/ t! y1 H5 [" A1、卸载nodejs重新安装一遍  p" d  [4 U  o+ s" W4 s% C

" L/ D) n$ y. A, i6 F1 z+ \& z4 B2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org. C( y8 M5 `: X* f; e/ U/ }

6 U& X( a- v, T7 D# E' V: x3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools- A0 N2 T* x4 W. }; m
————————————————8 K: B( ?# G8 ?; c1 [: G
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。# B& K3 f1 \$ f% z9 ]; ^, Q; S1 v
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

529

回帖

3524

积分

管理员

积分
3524
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7+ p: |7 g. C5 f

- l! L  D( b6 |由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
6 U  ~. p! D, t5 O( W1 ]+ i$ s$ s% T6 w/ V+ U8 F
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!  a/ R, {" S& _2 R. r+ h8 k% z* d
————————————————9 i& z+ p6 o: S& }: D( W
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
4 y" r- f2 k( C原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-16 22:28 , Processed in 0.014533 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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