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

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

[复制链接]

524

主题

676

回帖

4597

积分

管理员

积分
4597
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:* m" c  m. x6 w2 S0 ^
```bash
0 J$ W$ W0 X7 c0 K; R" ]( D3 agyp ERR! find VS
. {* f1 Z0 G# R& F+ z7 G) igyp ERR! find VS msvs_version not set from command line or npm config1 d% V+ t0 L0 t+ Z' @6 Z3 `
gyp ERR! find VS running in VS Command Prompt, installation path is:
; _. y2 A. b  A( U7 pgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"/ o& C$ O, ~6 _  M
gyp ERR! find VS - will only use this version  F2 Q+ x' Y& U. Q8 H- z/ q, I
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer  Y, N5 |2 R- g/ c4 `: {, L
gyp ERR! find VS looking for Visual Studio 2015
, x; k4 Q/ y0 N- Zgyp ERR! find VS - not found6 E" k9 O: q0 b  S0 E+ U* A
gyp ERR! find VS looking for Visual Studio 2013# g# l1 g* d, N* ?# B
gyp ERR! find VS - not found5 v' @: V1 ]0 i
gyp ERR! find VS- w: V! ~. Y: a; o7 D7 e$ E
gyp ERR! find VS **************************************************************
" Z/ K6 U, l% E& C% z+ n( a8 p5 ngyp ERR! find VS You need to install the latest version of Visual Studio, v) b; o4 A' F2 I8 T" Q
gyp ERR! find VS including the "Desktop development with C++" workload.
: L8 I4 a. g5 J& `; g2 tgyp ERR! find VS For more information consult the documentation at:
1 n5 j* q7 o# |- A: C* dgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
2 M$ Y& B. `2 n/ S2 rgyp ERR! find VS **************************************************************
* `, u9 g) M1 lgyp ERR! find VS
& j9 P  U) t( `) W/ E  Agyp ERR! configure error
+ U* B/ D+ y' Lgyp ERR! stack Error: Could not find any Visual Studio installation to use
9 r/ w( T3 D+ x$ `; I2 b2 Qgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu! {- U+ v* g+ p$ w. w4 J
dio.js:121:47)0 H2 w+ C: h# x1 X
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16" A8 E" {5 J, W1 N: \
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
; W9 m. ?" w5 h. ^; K2 }& Dgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7" p+ R0 E# ?: k2 v$ S- l; o
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
/ h7 Z  i3 v( _+ w4 J$ `gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)+ z  t  E$ f2 `3 r- z' B
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)% V0 N4 j! U. Y% o5 T
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
6 @4 c( w8 @3 w$ D2 D' \& Jgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)4 `" k  l6 b, J, T1 a# N) E4 u
gyp ERR! System Windows_NT 10.0.15063

& P4 a& C4 Q; {
0 X/ q/ g5 \$ j! N5 {1 L解决办法
, v: Z; Z; z: j/ l0 \1、卸载nodejs重新安装一遍0 A# v- R- F$ Y+ b4 x+ x5 S3 ]
% A& L% ^1 e. p  I# W4 Z& z
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
$ }/ ^- U1 L! Y
, {7 u' i% ]' H& J2 w% a3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools" i0 p& {) j8 \6 b
————————————————
4 C1 F+ A# ~1 X! Y版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
8 v1 L9 e. N7 `* i原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
欢迎定制:13928122889
回复

使用道具 举报

524

主题

676

回帖

4597

积分

管理员

积分
4597
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
: ^, k; S! |' j/ e0 z0 M( ]& j& ]3 E/ U. i  U
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
8 B8 |9 ^0 A: I+ A9 k
) ~/ b. ]. e+ j然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
: O; j3 g% g1 s3 h# [- g! M) v————————————————0 Y: y3 C$ v$ g0 w5 S7 R2 I1 K
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
& x# a0 X- j* B2 G5 s  K) d" w原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
欢迎定制:13928122889
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-18 20:09 , Processed in 0.018457 second(s), 3 queries , Redis On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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