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

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

[复制链接]

346

主题

559

回帖

3656

积分

管理员

积分
3656
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:; m# h. ~+ S  A8 k+ C1 k
```bash
7 y2 T2 X$ n- T& \. H# W  J! D+ Qgyp ERR! find VS# a- v! v  S4 f, \
gyp ERR! find VS msvs_version not set from command line or npm config. }5 u# @9 @8 J% l) ^
gyp ERR! find VS running in VS Command Prompt, installation path is:- |& {4 ~* p3 R: e$ ~$ x# K
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"2 b% D: J3 c8 _2 b) s+ y
gyp ERR! find VS - will only use this version
3 j4 P5 {' L/ r; [" igyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
% X' ^. I- _( l4 Agyp ERR! find VS looking for Visual Studio 2015- Q8 \: @6 u8 k! a- v6 N
gyp ERR! find VS - not found+ `3 D; k- h; J0 Q  S
gyp ERR! find VS looking for Visual Studio 2013
$ R/ ]" P2 T8 i# ]6 Agyp ERR! find VS - not found
7 f. _6 b4 ?" q! A8 Ggyp ERR! find VS: |" b$ V/ O5 r3 @3 \( W1 U
gyp ERR! find VS **************************************************************
7 L( }* @. \3 @& e7 ^1 Ugyp ERR! find VS You need to install the latest version of Visual Studio
. k% ^& Q5 j8 V) a8 q! Z3 |, Kgyp ERR! find VS including the "Desktop development with C++" workload.0 _' V, V% _" q- f7 H1 Y5 T
gyp ERR! find VS For more information consult the documentation at:
+ r# d# Q) Z9 I2 Agyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
0 z, }1 E' ?! P6 Dgyp ERR! find VS **************************************************************/ `- P( x* w0 y+ y2 i
gyp ERR! find VS
6 }% E3 g( `9 v" p" L& Hgyp ERR! configure error$ e1 k1 m2 Z" m
gyp ERR! stack Error: Could not find any Visual Studio installation to use( |; P4 l3 P1 r' z
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu9 B6 ^1 V4 J! E+ E, _% p! r
dio.js:121:47)- ?4 p: i: j+ [6 x7 b; v% v% A& @) b
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16& }3 R* y; J* C! t& V, S* e
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
+ h: g: i6 ~; u  t7 ygyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7+ E0 m' w. _, ~& [+ C7 ?
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16, I- W6 X5 N8 v  p
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)5 G) h0 r/ f- h; i. q0 }
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
) j+ m; V2 E) T3 Ygyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)3 @# ~0 L4 Z9 u+ X; H6 c
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
* A/ S0 ^, m7 A2 \  w, R: Lgyp ERR! System Windows_NT 10.0.15063
: A6 r) c% E/ A6 H6 a. a
& W7 \- T- D# @+ `
解决办法) t3 h5 y: V) M, `; u' V1 v+ j
1、卸载nodejs重新安装一遍  J4 Q7 k/ ]/ K) }: u6 G( K+ O
! o! f5 \5 _; T+ ~
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
- D; Z  N( A6 e1 S& Z! A1 ^8 n( S! a6 N* {1 \4 ]# Y& f9 ^
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
: f( q) c' W% ^9 v9 V————————————————- V% r- C( W. M' e
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。4 e7 d  n" M0 k% |2 c2 i8 F2 ]
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

346

主题

559

回帖

3656

积分

管理员

积分
3656
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
9 o' y$ d. n6 C1 W& v1 f: w) R6 @4 n7 q) y3 G6 M# p7 E* u* m) H
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。7 K* ?7 G- s: _. f; g( [: N# o

, k8 y) e) e6 ^! ?' t$ W然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
# u6 D7 q# n/ I0 ~( m4 Q4 \% t8 [————————————————; A6 o" v6 O# I- s. R2 {# {
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。4 _8 _* `8 d. `, `, W" y& g$ F9 e
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-5 03:48 , Processed in 0.012116 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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