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

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

[复制链接]

331

主题

511

回帖

3347

积分

管理员

积分
3347
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:. E- E# p1 Q* {5 f" @. H
```bash
0 S6 m+ ]1 d; m: `gyp ERR! find VS; S' \( w+ p" g0 B
gyp ERR! find VS msvs_version not set from command line or npm config$ r; Z8 X3 ]& ?! K+ J/ B
gyp ERR! find VS running in VS Command Prompt, installation path is:
1 a7 S" i' p% ~gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
& I1 \/ E2 Z8 T0 ogyp ERR! find VS - will only use this version
5 I' ~- k% y8 n# _' g6 |gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
# K; b' L$ \/ x7 tgyp ERR! find VS looking for Visual Studio 2015
, O  B% S  g( I9 v! H# @gyp ERR! find VS - not found* L9 K$ R4 `6 E$ j& X2 [
gyp ERR! find VS looking for Visual Studio 2013
( T) D+ J6 O! a$ mgyp ERR! find VS - not found$ u- D: Q5 l0 p6 v5 n3 k+ d7 V
gyp ERR! find VS- N& R9 w+ Z# V+ y" o" u
gyp ERR! find VS **************************************************************
! b  {* p  b. B/ J7 \gyp ERR! find VS You need to install the latest version of Visual Studio) J; G( `  k5 J1 y
gyp ERR! find VS including the "Desktop development with C++" workload.
5 }* U* i; I7 Ggyp ERR! find VS For more information consult the documentation at:' y  ~" N) R2 b
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows# L: o2 W" [; J/ w
gyp ERR! find VS **************************************************************' F3 V2 \" ^! t, a. F) O# E4 E. e
gyp ERR! find VS  L0 o8 t& c- D) u) ^3 l
gyp ERR! configure error
; o! q3 R3 r: g+ }- \4 H/ Ogyp ERR! stack Error: Could not find any Visual Studio installation to use' n4 e3 r7 V. h. I4 |) n
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu: @% U7 n: G7 E6 I6 p* X4 \
dio.js:121:47)4 l1 Z, j. h5 ~0 s- h
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
' H, ]1 p  c* u3 M& ?gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16, U3 A# y$ c$ s+ H
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7! T9 [$ W' q9 D, _& a2 K! w
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16/ M# j- S& p+ J& o# v) M! Q
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)3 o* }" Q) W& P9 O1 j4 C0 ]9 I9 c
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)9 C2 T% U, x; H2 ]- D& a6 \
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)" ~  {, M8 B4 c. ?9 a/ O$ L
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
2 Y) v' o# S  J7 W6 W/ a8 Q$ T6 jgyp ERR! System Windows_NT 10.0.15063
# t, |: M8 Q  ^. x( |! m

5 }- k3 u3 a' N' j* E, A解决办法0 q5 u& F$ z2 D" V7 c* _  A
1、卸载nodejs重新安装一遍" X. c8 ]  Z1 b
* ?. z4 D8 x7 b4 i8 L- y3 S- {
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org& L! l  ]8 Q- k8 I: ~( A

7 x# k* o; D8 g" l3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
  z, h- A3 P5 D; e" N( C8 l! X6 v————————————————1 e' a7 E0 i4 R+ N2 b
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。4 |( U  B0 e2 [- w" d
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

331

主题

511

回帖

3347

积分

管理员

积分
3347
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
9 {7 @3 O% R  F2 s) U* k+ v5 K( `+ p* Q5 \0 ]" i- r  x6 J
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。! m7 w9 H- G) ~6 h6 U2 r

5 y8 N3 p' E+ e8 P9 w然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
! B( a5 L* R8 D3 A& }5 X& c5 [2 l$ d( U————————————————7 f5 O6 c( a; `
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。1 c4 B# ]7 C3 o
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|通达产控投资 ( 粤ICP备2023021749号-1|粤公网安备 44030402006137号 )

GMT+8, 2025-11-16 02:04 , Processed in 0.065676 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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