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

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

[复制链接]

347

主题

565

回帖

3685

积分

管理员

积分
3685
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
, z3 u/ z- p0 r$ Z
```bash( y" [5 m  ^5 m0 s
gyp ERR! find VS2 O, X9 l% n6 I. c. u
gyp ERR! find VS msvs_version not set from command line or npm config/ F5 U/ y4 h( @' I2 X7 T$ f6 }3 u
gyp ERR! find VS running in VS Command Prompt, installation path is:
2 N: H+ y& k1 Q& G! j1 |gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
7 u2 X" u' ?7 K9 u9 u' @7 k+ K9 bgyp ERR! find VS - will only use this version
0 V1 _4 }' P# u' Y6 r& ^' M+ \* {- Hgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer7 {# ^, m0 X; N: K9 _8 G
gyp ERR! find VS looking for Visual Studio 2015% v: r, m' f6 _/ Z& Q: I
gyp ERR! find VS - not found
  ?; e& N. H) X; G8 e9 ~. _% O. _gyp ERR! find VS looking for Visual Studio 2013
4 W! V6 y- q, _: X9 b) Z1 Lgyp ERR! find VS - not found0 C! q# N" Z: J& ]9 x9 S
gyp ERR! find VS
* Q3 a; A$ e! A+ a, y- c; S7 M) ^gyp ERR! find VS **************************************************************% f. v) y) h, K  d/ g
gyp ERR! find VS You need to install the latest version of Visual Studio5 B1 ~" S3 f1 J- X7 Y
gyp ERR! find VS including the "Desktop development with C++" workload.
3 }: n, P( ~  E- V0 N) _gyp ERR! find VS For more information consult the documentation at:; B+ d' ~1 I( |# O
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows3 v/ m- Z  Q8 H6 N1 [+ g
gyp ERR! find VS **************************************************************- Z# [/ q, {% }% Y3 M+ A
gyp ERR! find VS) R1 v$ w# s- k3 I9 Z
gyp ERR! configure error& P4 A. E3 }$ O7 s3 d
gyp ERR! stack Error: Could not find any Visual Studio installation to use3 e; d& W1 d: u7 M3 M/ @
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
! v9 c: O: ?( r/ E/ o2 Ydio.js:121:47)9 i1 f. N+ d$ c/ J: J: d
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:162 _# E- k1 t' e( A8 }' x) E
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16: Q0 m) }6 x1 a
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:77 o+ r$ j: l  }: A8 R2 G) P
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
6 `: {  `; L/ }8 i; Agyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)* K$ o* L5 |" Q; l9 @$ Q. `
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
9 s, K( e  @6 h8 hgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
. ]1 \" C- K* ?* ~1 R3 u: `( H. @gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
4 P% D- S9 v) L& ngyp ERR! System Windows_NT 10.0.15063
' N! |6 h  h5 s% k" @" ?/ r) \

  j6 T, J* d8 `  {. l% Q0 W4 \3 ?: j解决办法
7 N7 D% X4 \, C$ C8 v1、卸载nodejs重新安装一遍8 V: e3 v* ?, {* t* D
/ d# l+ ^9 P5 K8 ]9 `' }: ?3 {8 z
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
! I) {$ ]+ ]2 C; @5 O- |
" F7 Z9 F8 w/ K3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
6 G+ c$ M/ S; i  h————————————————
2 o2 `/ y" u6 `+ ^/ m$ Q2 D/ k版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
: }! V% n0 [& z! [, @, _原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

565

回帖

3685

积分

管理员

积分
3685
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7' _/ R- W6 z: |+ y$ Y8 Z' y
0 d! ?& F3 L& u5 V
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
: l  N$ d& j, G3 p  f/ o, C1 Q3 E- Z1 A
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!7 c; n1 T2 ]* D7 E3 u
————————————————
* p+ c  n: d/ _% ~( w" |# g版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
) Z" v. f& Q9 z, ^9 A原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-17 12:40 , Processed in 0.016065 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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