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

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

[复制链接]

331

主题

511

回帖

3355

积分

管理员

积分
3355
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
3 K( M' v5 D2 o+ p, W6 J0 K
```bash8 E3 ~: G2 k1 K- y7 {' e
gyp ERR! find VS3 G. }4 s3 K5 \  @9 _: U
gyp ERR! find VS msvs_version not set from command line or npm config% r* I6 R& [! K! q& w7 H% ~
gyp ERR! find VS running in VS Command Prompt, installation path is:; f: c8 }2 }! v; W9 h: d
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
3 R9 `, t7 z" ?2 Qgyp ERR! find VS - will only use this version
; p) W( k6 m0 X5 W2 Z. tgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer  a* A( @; l2 j+ P+ r; D% F% h
gyp ERR! find VS looking for Visual Studio 2015
- R5 f, L" s5 E: w. a9 Cgyp ERR! find VS - not found
" B  C: C3 Z& E+ {) {$ q1 E" Tgyp ERR! find VS looking for Visual Studio 2013( S/ k1 k9 p4 e' A! x! L( Q' {
gyp ERR! find VS - not found5 G3 z. u) }& s8 @5 C- m8 v
gyp ERR! find VS8 C, T: U: i9 T1 W
gyp ERR! find VS **************************************************************
/ N; D( ~! C  P  fgyp ERR! find VS You need to install the latest version of Visual Studio
2 j( L3 Q/ D3 l( C6 C2 L( P  r3 [* Xgyp ERR! find VS including the "Desktop development with C++" workload.
2 t+ ~6 r  z$ ^! _1 _gyp ERR! find VS For more information consult the documentation at:; g7 ~7 k% T+ f' k
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows5 `' |, R+ A8 `
gyp ERR! find VS **************************************************************
5 D8 p0 D; z# V$ h1 D2 `5 lgyp ERR! find VS" Q$ q, R, z6 t" K$ n" V: t
gyp ERR! configure error" p' E$ M' I) k6 O- @* u
gyp ERR! stack Error: Could not find any Visual Studio installation to use7 T$ l: P' }3 D' r2 |1 I6 V( O
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu0 Z* A2 ?( `' u, X5 _6 |
dio.js:121:47): g! `6 \6 O" k; j) V. Z6 ~" g4 c
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
4 X, M) L" J2 w' a) }; jgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:160 j; K3 l1 I5 Q2 U; [# c1 l; A3 d
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
; W/ z& ~. r2 n, O' w- G3 Kgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16" ~4 L3 A% [( E# A* L; C
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
8 {: ?7 `; {& p0 jgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
4 p4 }9 V. f- ?6 Tgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
+ ~0 N) P; ]3 j9 @0 b5 f( d" Q' Jgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
5 J" V8 [+ {: rgyp ERR! System Windows_NT 10.0.15063

& _! K( a- j  [' g% {0 X
2 Z' X( ^8 C1 b: ~解决办法9 ~: s( |  z8 b1 ^/ A* v
1、卸载nodejs重新安装一遍
' }" _& C1 ^4 b: X$ t# S" z. E6 ]' t) Y- b# I, O8 F8 }# [1 M8 K; I
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
+ Q  a( s$ W  ^! Z3 u& V: V" X/ e5 f
* y  a& K  E3 P4 [+ G, Z( \8 ?3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools% Z0 E( D7 y  h7 @5 |7 s, n
————————————————
' F- L  ]. z) x0 z) Q8 E版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。: j3 P: ^  ^$ C- x
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

331

主题

511

回帖

3355

积分

管理员

积分
3355
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
/ u& \) f1 U( A; l$ a6 _0 ]" c
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
4 G" f  R6 l3 D& N0 i) |" f; Q, `4 s  \, k0 y8 v
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!5 ~1 N/ l" G8 ^) D7 [# z
————————————————! {- C4 v2 I0 `+ M
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。( |2 k8 Z8 g& f( p6 U0 s0 `* O  h
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-21 05:50 , Processed in 0.066061 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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