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

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

[复制链接]

340

主题

522

回帖

3494

积分

管理员

积分
3494
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
0 Y0 {! \( n, h8 b
```bash
9 K# G: f1 H1 X$ agyp ERR! find VS
8 f7 |! Z8 k) y: r+ [" Igyp ERR! find VS msvs_version not set from command line or npm config
$ ^  g% m9 C% u0 v7 X& L3 m! sgyp ERR! find VS running in VS Command Prompt, installation path is:
; i5 Q6 W% Z' L$ e5 `5 Qgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"6 q( _# ~) }9 @% Q
gyp ERR! find VS - will only use this version' e5 Z" W7 c" ~1 m" X
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
- q8 V. w! }5 E$ A3 W: Mgyp ERR! find VS looking for Visual Studio 2015' [$ I- K( }( v# Y  ?, c
gyp ERR! find VS - not found
, [5 l2 {" Q3 E4 S3 j6 Lgyp ERR! find VS looking for Visual Studio 2013
! ]& _* r" {+ r+ }. S, @$ Y. E/ agyp ERR! find VS - not found% g0 l# @4 f9 b# e
gyp ERR! find VS! f) @5 ^5 u2 y' {6 {, B8 A3 ?
gyp ERR! find VS **************************************************************
( {- U& a3 p6 q& k) H' o7 l3 Ngyp ERR! find VS You need to install the latest version of Visual Studio; z, b7 z9 \& o+ W3 n
gyp ERR! find VS including the "Desktop development with C++" workload.: X, }- i$ V" N5 L% O4 r" r/ A
gyp ERR! find VS For more information consult the documentation at:
; v+ a" F/ ]" t% `5 q$ d* Qgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows% v# A# p# U/ }2 A& w$ b
gyp ERR! find VS **************************************************************+ X+ y6 `; H/ `7 _- N6 ~' k
gyp ERR! find VS
4 B( C' Q! H. I% C/ P0 }  j8 Fgyp ERR! configure error3 u) B2 X2 k9 E' b. t- u% U
gyp ERR! stack Error: Could not find any Visual Studio installation to use& `) g( @" |; R1 n
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu) Q  J4 ]  @4 |- A9 {( q# q
dio.js:121:47)7 {5 I; V& o" K- S6 D
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
+ u8 ?! f) A5 j, V% [* Y+ ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
: |( _: ^4 W  S2 |gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
# `! Y6 H+ D9 K( o4 T  n, mgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16  Y: Z  O& ]6 O) a  Y* d
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5): F+ g4 |0 W' x4 p5 {
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)* _3 _1 S: p- |3 W; V+ K$ s
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
6 k: O, Z) z! |. W: sgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
" n' A5 J! }3 E, a+ x6 Ogyp ERR! System Windows_NT 10.0.15063
8 n- D6 n. h7 m
  P' i8 c2 J. H5 K: \: ^, W
解决办法. H1 Z: ~" E  r
1、卸载nodejs重新安装一遍0 E% t7 g  _4 f6 c

8 s% C8 t4 \4 ]5 a& a" B. Q' w, H2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
) f4 P4 s. `$ v5 \" M8 I* ?  B8 |: U  h& p( b7 o) R2 ~! r
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools- H* H# G$ O5 ?+ @  C8 F* P$ |
————————————————
* I0 f6 ^# p. o' R* H版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。6 T  o) A4 {0 w1 o
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

522

回帖

3494

积分

管理员

积分
3494
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
! p; Y$ W5 L" w2 i) ?0 a
8 g2 @$ z. _, m/ j) K由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
* y4 `/ {2 P$ m- O: M2 R" X% r& u' A, ?& _& A5 |" R7 [! S* R1 \
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
% B# I) [" m6 [3 d" X4 ^9 c————————————————
/ G5 |  C3 [  W9 K6 ?版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
+ u- d5 V, L7 n9 y6 y7 F& c原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-12 01:08 , Processed in 0.020216 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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