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

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

[复制链接]

338

主题

520

回帖

3454

积分

管理员

积分
3454
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
9 ^: j& Q6 G+ a1 e# E
```bash
9 a' {, g+ n9 i9 q3 c3 Sgyp ERR! find VS
, H6 B; t# r% h/ `( {gyp ERR! find VS msvs_version not set from command line or npm config9 {8 {: x# o: r4 j/ d4 m7 c' [
gyp ERR! find VS running in VS Command Prompt, installation path is:
! h$ r0 X, m) n5 V) b/ p2 }7 hgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"5 L& `! R3 @0 ?- ]; q
gyp ERR! find VS - will only use this version
+ Q, ]' e! I! N/ K' W5 e9 o' Ngyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer* P8 ], ~2 h' F
gyp ERR! find VS looking for Visual Studio 2015
; Z3 y6 F7 s  ngyp ERR! find VS - not found' {/ B& W/ _- [3 D
gyp ERR! find VS looking for Visual Studio 2013+ G7 v; V( v) M7 i8 Q+ B: R
gyp ERR! find VS - not found, Y1 I& P$ x7 p0 ~
gyp ERR! find VS& l: _6 g! S6 t+ C
gyp ERR! find VS **************************************************************/ {# h9 P* X/ b
gyp ERR! find VS You need to install the latest version of Visual Studio
* U, C. Y- j0 Cgyp ERR! find VS including the "Desktop development with C++" workload.
, Z2 h) W3 N3 ^# h: ngyp ERR! find VS For more information consult the documentation at:' n* x  S& y( o. ^
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
1 {5 K7 _* s' Y9 S; q) P) sgyp ERR! find VS **************************************************************
9 W' k: I7 N; R2 ~$ pgyp ERR! find VS9 S( |$ K  V& {3 ^
gyp ERR! configure error- e& a+ i% K7 A: ^/ s
gyp ERR! stack Error: Could not find any Visual Studio installation to use7 V" E7 W! q# m1 k  B/ o
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
7 ?9 `( v" S1 W7 ^% v$ Wdio.js:121:47)
8 P# r! T6 d% i/ t  W0 G0 qgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:160 |: }# M/ k. q; \3 ]
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
9 S; N- Z8 O4 L. X3 Ngyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7# B! `) a5 j+ L8 z( f4 [9 x+ {
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16. @( {: W" f) W: X
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
+ m0 y. ]9 g4 vgyp ERR! stack     at ChildProcess.emit (events.js:315:20)2 ~0 J( B2 [! a9 f
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
' v' j+ s* C. r. a& n9 O) P2 tgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
$ `  _+ T" L4 k* pgyp ERR! System Windows_NT 10.0.15063
( O4 s( k$ U7 c5 S/ N9 K
& U' @$ _- ~% k: ]
解决办法! s- c9 g8 X; M3 C2 z
1、卸载nodejs重新安装一遍
- r8 T4 ]8 R3 W0 V  {9 q5 R$ \) G$ V  [4 ~9 x
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
7 }; c* Q7 A9 h4 l  L* [8 g& X0 C3 ?  B5 w; x% z
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
) u$ i8 v; t! ]' a3 ?————————————————4 m( l8 R) m3 c4 i$ C
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。- S% }6 V; P; s5 A# G( J
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

520

回帖

3454

积分

管理员

积分
3454
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
* O, |. M% I9 f* [% U
4 K& M6 `. ~7 A8 r, F' M- f由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
( |! h' _. m/ V" E& \8 M6 Q, t  }* w% u& h2 b' b1 L( y
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!5 I3 p$ U2 W$ I
————————————————8 M9 v1 t) L- p" U# @, T5 g
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
8 Z' h) P4 A( o/ l, p! G7 h原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-24 01:25 , Processed in 0.016464 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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