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

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

[复制链接]

332

主题

513

回帖

3372

积分

管理员

积分
3372
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:0 D4 ?8 f* P: e
```bash; q: H* L, ^- Z* D* f
gyp ERR! find VS2 X' p* T, c9 R2 [' y1 B5 @) ^
gyp ERR! find VS msvs_version not set from command line or npm config
5 w0 p$ S) c+ v8 j  V  Jgyp ERR! find VS running in VS Command Prompt, installation path is:
% w; R/ `" Y+ o4 ^7 M& k/ vgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
' \% }, u2 O6 {% E8 Ugyp ERR! find VS - will only use this version& i) B7 g% z6 b" U* S% n# Y
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
% T' ?6 T' R$ A# O" F  V) bgyp ERR! find VS looking for Visual Studio 2015
6 m: i6 \% v3 T9 l4 l1 y& Mgyp ERR! find VS - not found7 Z" _$ A* S6 L+ [) U( }: w
gyp ERR! find VS looking for Visual Studio 2013
8 f* P0 J# K7 q3 K% ogyp ERR! find VS - not found
3 M( \1 W2 Q# l4 e1 j. cgyp ERR! find VS
+ A: D. M0 P% I* v, f& Zgyp ERR! find VS **************************************************************
( ^: O% t/ c" ]2 y* V5 M4 ngyp ERR! find VS You need to install the latest version of Visual Studio- i6 h" ?! Y9 z. D8 f, X
gyp ERR! find VS including the "Desktop development with C++" workload.
# x- R; A# v9 @. U2 \- ]2 ]. [gyp ERR! find VS For more information consult the documentation at:
/ K" Y9 H7 E1 {5 w9 U( h6 Ugyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows" ~# t5 u, j" M3 f: }' S. G
gyp ERR! find VS **************************************************************
1 t+ p' K+ A- T* }2 J+ f/ ygyp ERR! find VS
9 o) v. |; j) }! q: dgyp ERR! configure error& I! f5 v5 g: H" k% X
gyp ERR! stack Error: Could not find any Visual Studio installation to use
0 _9 U. M6 ^7 J6 a) xgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu# n1 W% }  Y* X9 y& j1 |
dio.js:121:47)
/ g0 W8 B' T3 V6 Egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:163 C9 Z7 _2 E& z& N& _% c
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16  T3 l! Q6 U5 B. t3 a  w- \- a7 {/ b5 K
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:73 Q3 K, D: d4 B2 z0 C( g4 Q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16$ O4 _; U; e. y7 m- Z3 o, c
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
0 m6 @+ Y& O) N9 x+ zgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
/ {* x% u3 v$ |gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
6 s. V8 `) v6 t# ]: _. n7 qgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
- A, F* j, D! J0 _! Fgyp ERR! System Windows_NT 10.0.15063

) g/ [2 v. F( A. g% D  X3 P* k4 ?. |; [4 d3 @( f
解决办法
. D& x8 Y) X; {( e, b! x( V1、卸载nodejs重新安装一遍
! u5 F  p7 ^6 W) D- _+ S$ N& y- \9 w+ `/ Z- e5 y) m  V. G+ A3 _$ r6 X
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
: d2 m: w" G- @" T) e# Q, B; N
4 }% K( b7 B$ H- Q. h8 |3 H! B! J3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
4 F4 J5 r. v1 C* e0 X+ q' q————————————————8 Y# B2 t/ r9 S) W# J* G) q9 Q
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。$ O( p& ^1 V$ C
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

332

主题

513

回帖

3372

积分

管理员

积分
3372
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7( R; D5 _. R) e; b$ [  S

2 e2 b" J3 u; c* k, N由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。8 C" r  B4 b/ |

5 n9 ]/ T$ f$ m然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
  i; ]+ R6 J, y2 d9 T————————————————1 C: w2 y0 A* B, y
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。/ y7 Y: b+ q8 U& z: X0 b
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-25 18:32 , Processed in 0.083866 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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