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

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

[复制链接]

329

主题

510

回帖

3301

积分

管理员

积分
3301
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
( `6 K0 w+ _% A* K) Y
```bash9 ~/ c- Y/ |0 c9 H# c
gyp ERR! find VS$ A( Q7 ^: E5 X- ^
gyp ERR! find VS msvs_version not set from command line or npm config
% U( C$ Q- z& U& [" `2 X1 x7 h2 f9 Agyp ERR! find VS running in VS Command Prompt, installation path is:. z# E3 j/ F& t' i5 _1 C$ s
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
+ A6 V2 P% H# m3 @9 V1 ngyp ERR! find VS - will only use this version
! v; W$ c, P+ ~3 C# Qgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
- P# X* ]: P8 L9 v4 Cgyp ERR! find VS looking for Visual Studio 2015
( u4 K% M. R3 m0 Ugyp ERR! find VS - not found: w! H# ~9 u. x# D5 ?4 X: O4 h2 _
gyp ERR! find VS looking for Visual Studio 2013* }8 K3 E, y9 b& w3 @4 L
gyp ERR! find VS - not found
+ @) c/ f! z( B% vgyp ERR! find VS
- w! j3 S1 z* h7 P! m9 igyp ERR! find VS **************************************************************1 N" z8 q  q; E5 [
gyp ERR! find VS You need to install the latest version of Visual Studio
# l. G' ~! L- b- V+ Y4 {gyp ERR! find VS including the "Desktop development with C++" workload.) X# z! Y5 M! z; N- X: f7 ~
gyp ERR! find VS For more information consult the documentation at:
( s+ J; Y3 c' T# i4 z. Vgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
. C  w+ c: B$ M; `gyp ERR! find VS **************************************************************' D1 s- Y0 ]( t
gyp ERR! find VS% O) k9 a% k' m7 |& Z9 M
gyp ERR! configure error
9 Q" Y/ `) t7 `( X! b6 a0 sgyp ERR! stack Error: Could not find any Visual Studio installation to use
& S: t2 Z) k8 t0 L/ J; t0 k: Cgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu' D9 e6 h) y7 A5 p, J
dio.js:121:47)
% _! ~1 h& _7 N" z. f, Ugyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16; U3 g( _# {( E) ^" z' A
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:168 c9 E: E0 k( z% ^/ r
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
- ~, y# H/ B8 K3 ~gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16+ c5 m) j1 l9 \$ E; b0 `; K
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
' D# z" D' e3 |8 rgyp ERR! stack     at ChildProcess.emit (events.js:315:20)( b4 j$ C9 q) T5 J
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
( n7 W) Q9 R) t/ N# Pgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)) D' ]. M) T' q$ L
gyp ERR! System Windows_NT 10.0.15063

3 S, h) {! `" N' `& r4 i. w. o1 [0 [, r& o6 f$ X
解决办法
) V" F1 l6 A/ _1、卸载nodejs重新安装一遍0 G0 H7 r( Y& V( [1 H; _2 x

" [: n/ P6 \& E" p. y: p! x+ V2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
$ L* e% a3 }/ L; H( @
) y  U! N$ a5 }% b' m. S1 A" s3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools0 B. V$ C4 f% p3 J
————————————————2 N: r; r+ P+ A& S8 n+ l) K8 T
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
% b1 I1 I2 L) k) X- {( u原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

329

主题

510

回帖

3301

积分

管理员

积分
3301
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
" N* t* E# U1 D' q# X+ e, y  \) w( U/ T% N
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。2 Z6 @* Z; Q% s9 v
8 f( x8 }* w, u7 H
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
$ F; n) g; c) H9 v7 j% ]& }' x————————————————  R8 W' q( T3 z( k: e% ^
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。( Z# @8 R  q' f# U8 _& E
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-21 00:40 , Processed in 0.082648 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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