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

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

[复制链接]

408

主题

596

回帖

4038

积分

管理员

积分
4038
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
: A# U' ?7 y$ s8 |
```bash3 G6 P. e1 p1 T" F
gyp ERR! find VS
$ a, F* S- O% R/ ]9 ogyp ERR! find VS msvs_version not set from command line or npm config% F: l. p( I: m
gyp ERR! find VS running in VS Command Prompt, installation path is:
1 I" ?& G% Y, x! M' K7 o, Bgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
. V# J  E% H* X' J0 @% v1 E+ Pgyp ERR! find VS - will only use this version
! v# `. Y/ `4 e1 b) }gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer8 r! o8 ^) y/ [* ~! t) e
gyp ERR! find VS looking for Visual Studio 20155 t0 @7 t1 ]+ r# l. p" L  Q  J
gyp ERR! find VS - not found
1 ~, R8 N) |8 tgyp ERR! find VS looking for Visual Studio 20132 s( P, ]4 `1 W! a' g
gyp ERR! find VS - not found
4 p, s. w6 d4 Q7 ]' J8 a, hgyp ERR! find VS: b6 b3 |. e0 C& I0 {" r) F
gyp ERR! find VS **************************************************************
9 U- b# l' R! U3 K5 ~gyp ERR! find VS You need to install the latest version of Visual Studio
) L; ^+ E6 F0 A0 ?4 v4 r( hgyp ERR! find VS including the "Desktop development with C++" workload.0 t( K. I) u  G6 f
gyp ERR! find VS For more information consult the documentation at:* l/ |  ~- o' K/ b- H4 T3 ], g
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows* o  [( f5 K; D2 C
gyp ERR! find VS **************************************************************
& p9 r- T! N1 n9 ~gyp ERR! find VS
9 n. [# t& ^9 J2 E% lgyp ERR! configure error4 y* c2 t7 w2 U6 A% ]: U
gyp ERR! stack Error: Could not find any Visual Studio installation to use
( J) Q  n9 Z& X9 c, {gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
  @5 j% W6 t, W, `% d7 J5 bdio.js:121:47)
# l  ^" E$ G* r2 Tgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:161 ?3 Q$ U$ s+ T; N
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
$ @# a, G3 \3 E' |2 E0 jgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
7 _- y' [$ y  |6 |gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:169 m) y$ Y/ f0 D7 h: E
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
. s' s$ L1 A1 G) m; U( ngyp ERR! stack     at ChildProcess.emit (events.js:315:20)
9 h, x* S, M; g, o) T. \: ogyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
4 h. c- \( P: I: kgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
9 r+ X$ c7 `* S  p, a8 B7 C7 vgyp ERR! System Windows_NT 10.0.15063
. a; \$ q+ k# i4 e

. {+ Y3 L/ M9 E, q0 v2 e解决办法6 d: v5 W9 G& r! L1 Q5 C
1、卸载nodejs重新安装一遍0 O$ C" _) ]3 c0 S8 p' n8 r3 w
! v! N* ]  ~* l/ H3 j
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org0 g# F- n5 |  p8 Z. |2 f* |# d* g
8 X, |4 l- ~# s' J" G2 L
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
8 b# c, H. \  a6 i6 O* j; n: p————————————————, r: E6 U' d% Y
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。& R* C) y. a5 n3 F# w# s; v
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

408

主题

596

回帖

4038

积分

管理员

积分
4038
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7( x* s( x2 o( i% |/ f
4 S' F( l" ^$ r- X* x* X. h  N
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。( e& [* l* N/ p8 @  J

0 d+ m3 D3 F6 l0 @* a( N然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
( J% a( p$ R9 t/ ^& W————————————————
+ I( ~* u( _: X$ A版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。" v3 d) I/ J" z7 g( J. Q
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-10 04:36 , Processed in 0.547519 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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