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

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

[复制链接]

491

主题

662

回帖

4460

积分

管理员

积分
4460
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:0 U1 p' D4 k5 a. G8 H5 l
```bash
8 E% W: n- ~, U# `4 B5 fgyp ERR! find VS9 E" ~- h2 j$ i4 h) A2 O
gyp ERR! find VS msvs_version not set from command line or npm config
* J/ s3 @4 v$ b, A3 jgyp ERR! find VS running in VS Command Prompt, installation path is:
; g" V& R0 x) c" m, ^gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
7 V$ U9 G  `# [gyp ERR! find VS - will only use this version
8 q! i; M- Q0 n& {9 c/ w; r) Dgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
* G; @, T3 [9 Y9 f% k$ Agyp ERR! find VS looking for Visual Studio 2015* o3 a; o2 u# \# G! B1 A
gyp ERR! find VS - not found
: Z; N' ^, [8 s% ~1 Pgyp ERR! find VS looking for Visual Studio 2013
* ^0 c6 D/ ^( c/ Wgyp ERR! find VS - not found
) N9 P& f  e4 o/ Tgyp ERR! find VS" a: x0 B; `3 x) e! l+ H
gyp ERR! find VS **************************************************************8 u/ n' B. d  _6 A7 `; S2 I
gyp ERR! find VS You need to install the latest version of Visual Studio
4 \6 n- h" H" V, e; N' }gyp ERR! find VS including the "Desktop development with C++" workload.
2 \0 G8 z. A8 |# l9 k" ogyp ERR! find VS For more information consult the documentation at:
3 Q1 W* l$ U# g8 o  r# Zgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
) G) q$ p! e4 H/ x" k3 O6 [gyp ERR! find VS **************************************************************
& a# n" F' D1 C; w0 ?# Y. v; Vgyp ERR! find VS
5 B1 X) y. I; e8 j& `) d; rgyp ERR! configure error
% d+ A% _/ d) l: @- agyp ERR! stack Error: Could not find any Visual Studio installation to use5 N0 M0 s1 p/ R; e
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
# ?  `. P% |  B1 o' Z# X& w, Bdio.js:121:47)
0 t% i. U: S' Bgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
; J: C8 D3 y" t% p0 c* egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16) v/ q6 V0 J5 U) b- B7 y
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7% O; z9 x, v: f
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16) T1 ^, J5 U9 `( i: X
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)# i( d* _- v! g( s: N9 A
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)% `- A7 ^7 P+ p! H
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
  B! A1 j- B% |) M# Xgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
1 X& A: h" ~+ M: w# B+ g3 h9 h# Ogyp ERR! System Windows_NT 10.0.15063
, l6 a% [5 L7 c' W: ?' i2 q( e0 I
6 ]5 s; E) D* v: V
解决办法8 W  u7 _% c" n
1、卸载nodejs重新安装一遍# |  E/ r- v1 Q, |0 {

8 y7 H. J& E! b& k2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org' G* y6 I$ Y/ q" y1 L$ l  V/ u

) V4 V+ o8 n5 M8 Q4 L) b7 M3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
+ o/ C  [2 }3 o- x& H9 H/ `————————————————
# J2 w" t- P* a6 p* X, i! r版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
* V6 Z& b9 p  c* n+ _3 `# \8 G原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
欢迎定制:13928122889
回复

使用道具 举报

491

主题

662

回帖

4460

积分

管理员

积分
4460
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.72 W; B5 S  S+ {" c$ R/ ?
  @, k  L/ o  C$ a1 C
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
/ b, D; ]% ]7 i* X6 ?) Q+ H9 p: L2 ^* [- G4 v' ]4 v2 z
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!# p, G+ f, {* r% q% j1 V
————————————————9 b/ h# r. i) @! {5 f; F7 ]$ D; ?4 T
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
/ n7 N+ c0 e/ l5 ?原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
欢迎定制:13928122889
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-4 00:24 , Processed in 0.020254 second(s), 20 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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