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

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

[复制链接]

346

主题

561

回帖

3662

积分

管理员

积分
3662
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
+ i0 @( c/ L: J: @; G% G
```bash- E$ F" t( w$ C# s: G0 e4 s
gyp ERR! find VS* N5 a& C0 S! p! J# i. G
gyp ERR! find VS msvs_version not set from command line or npm config. g8 q4 ?3 u7 \5 i- \
gyp ERR! find VS running in VS Command Prompt, installation path is:( q3 B/ j3 n/ N* j7 R, \
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017") d' J) r0 ]' A3 e. x
gyp ERR! find VS - will only use this version2 j# F3 K. ~2 u) _% |
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
  R8 n8 y& W* R  tgyp ERR! find VS looking for Visual Studio 20152 f3 g& A: p4 |( N, y1 O9 x2 j
gyp ERR! find VS - not found& ~8 |" ]5 H  h! e& A( u- t- v9 }. q. @
gyp ERR! find VS looking for Visual Studio 2013) c$ v1 h) Z4 e2 m( a
gyp ERR! find VS - not found
" u+ y; ~! k0 V% Hgyp ERR! find VS1 q) a- b8 h" l* E9 R
gyp ERR! find VS **************************************************************
" v5 J5 c- Z% A2 [& a! ^gyp ERR! find VS You need to install the latest version of Visual Studio
* f3 f; l; \$ @( k+ hgyp ERR! find VS including the "Desktop development with C++" workload.
: u1 `/ G! ]2 sgyp ERR! find VS For more information consult the documentation at:4 V! u: q9 f3 R" |8 H0 k
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows7 I% e- P2 f4 Z3 f# @$ m/ o
gyp ERR! find VS **************************************************************& G5 J: c9 b1 s) Q) z1 \6 D
gyp ERR! find VS
8 p; b$ m# g7 X% G6 K0 Bgyp ERR! configure error: ?1 [0 Y' }" p: ~: s# e
gyp ERR! stack Error: Could not find any Visual Studio installation to use: Q% F! N5 i- m1 m0 K
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
$ D4 }( m1 k1 N- K9 A1 gdio.js:121:47)9 f9 ]0 H, `$ s8 L- l
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
% _+ q7 v. H1 k, u; H6 [( dgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:160 u" m' h9 ]0 x% n" B$ q- a9 L
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7: O) d2 T) O4 ?4 ?2 u# v
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
- T; _. A" ]8 e$ t( ygyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)3 b: |4 z. Y) w+ C9 O* [8 ?
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
! I9 |3 p( K3 J" m) p- I% b/ Jgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)4 U  c( H/ _( M5 o
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)5 F2 E1 R8 s6 W! m  j. E1 C
gyp ERR! System Windows_NT 10.0.15063
/ M% _2 |4 f! N1 n; Q

  l6 {, F  n, ~1 \& Y  E$ |& y解决办法  S9 |8 c+ b  r$ u$ j9 U! q2 D: V
1、卸载nodejs重新安装一遍- }0 E* Q" l3 T9 ~3 P& m
7 C$ P6 Q( Z% \. x6 ]
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org3 Y' j! k0 [/ D

3 ?; i9 O: p2 {$ N$ L3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
9 z4 M4 _7 r: U+ v1 E( C- u8 p————————————————4 A1 r  _( X* }  S% O9 \3 T8 B
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。0 F! \6 ?4 w6 I' h
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

346

主题

561

回帖

3662

积分

管理员

积分
3662
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7# h3 \$ m+ k3 x7 F/ y- h0 o# y) Y

* F  Q- v' ~- P9 e' B: {9 y: l由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
4 u) P) p; X' A1 \0 o
( `, E, z' Y1 A/ `$ l1 e' {) e1 i然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!( B  v& H/ m3 A$ [" _( L% }
————————————————
2 _+ t6 g# z. B1 s5 p! Q" _0 ^版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
/ b1 d1 |! [1 K3 R0 S; m原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-5 22:38 , Processed in 0.014679 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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