找回密码
 立即注册
查看: 1283|回复: 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 | 显示全部楼层 |阅读模式
报错信息:
* c3 j6 D; @' ]4 x, j" c7 C
```bash. Q& W6 h& n- F. `+ g8 {% N& h& W: t- |8 h8 O
gyp ERR! find VS, N% g& O: I0 r5 P! M& \* r8 d
gyp ERR! find VS msvs_version not set from command line or npm config
) g& p* I4 j* C' T/ Wgyp ERR! find VS running in VS Command Prompt, installation path is:
5 m" o! I5 N9 w) Ggyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
; q8 ^  m  ~0 p7 T5 F' {. `gyp ERR! find VS - will only use this version' }, B* u1 E. v( a
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer7 z. Z0 J# P4 a8 k
gyp ERR! find VS looking for Visual Studio 2015
" _  k. }$ N& i5 l5 `3 d! E% z: bgyp ERR! find VS - not found
8 _! F1 @  B, Tgyp ERR! find VS looking for Visual Studio 20133 I( A  ]8 l% d; `9 G; n0 c+ K
gyp ERR! find VS - not found
% S  d1 ?' u% C, V* i5 ]7 Mgyp ERR! find VS
9 ^9 ?6 v/ N/ V8 hgyp ERR! find VS **************************************************************
- g, K- b; Q, Q% O9 _$ N. q! cgyp ERR! find VS You need to install the latest version of Visual Studio0 E* ?+ x) A* M% j
gyp ERR! find VS including the "Desktop development with C++" workload.$ d# m; w) y" }1 ~" R
gyp ERR! find VS For more information consult the documentation at:
2 s1 U3 ^8 _3 k/ m3 o$ kgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
; X( b+ [- W0 W3 x) ]# ^gyp ERR! find VS **************************************************************
) b( u$ m2 C& u  Q: @* t$ Cgyp ERR! find VS
' x2 ?: G; Y! d) V# u7 |( S9 F( n9 v2 ]" vgyp ERR! configure error# G! A0 x8 |, m1 B4 \8 F: W9 q
gyp ERR! stack Error: Could not find any Visual Studio installation to use6 n* t  O5 ^: U% V- R  ^- |3 J8 W3 n
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu/ Q2 g; l1 `/ q' W" [; m8 n& T0 c" T
dio.js:121:47)
, p* e3 G# m( S- N  Q' dgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:165 C3 \3 U" C% K, n7 i( H: F
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
% {# y0 }, ^+ A' Ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
! @0 T) l2 Y  E% d8 agyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:160 b3 ?& t  A4 M
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
5 u3 S* v- K  T+ i. |gyp ERR! stack     at ChildProcess.emit (events.js:315:20)2 u' i6 M" ?% d9 N
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)* f6 K9 D+ o' |/ r3 }, d
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
4 E9 o/ _! K% `4 q2 g. x5 `! Z5 L3 Dgyp ERR! System Windows_NT 10.0.15063

) D6 a  J' R3 x8 z" r2 T% `0 O
& V7 ?3 g4 ]3 n9 c解决办法; K8 f' F) k, L" ?
1、卸载nodejs重新安装一遍& M2 k- A2 O' a8 M

7 d7 w" C2 Z/ V2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org( d& C- H0 U4 h9 i/ f8 S, Y7 a, k

% ^& A: y6 B4 \3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools" w  x& b0 b: F3 `/ p# e
————————————————4 E1 Y9 C& V( b6 c7 @5 I4 p$ }' n# n
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
9 H3 h8 T: n% y5 U原文链接: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
/ J1 r5 h6 m" w& m* O% p8 |6 i# Q" B9 B- B
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
' T7 \+ v% h' Q: P
& @+ R" f0 O4 M9 p& w  B然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
3 n) Y9 j1 S2 V+ X% |2 P2 i; }————————————————
) L# Y. p+ U9 r+ q4 H6 |. Z0 V版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
  @9 W4 P, S% X: ^/ C- i0 ]5 x原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-12 14:28 , Processed in 0.032249 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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