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

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

[复制链接]

340

主题

529

回帖

3528

积分

管理员

积分
3528
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
, p3 O, k# g1 a( ^- ^' l: u
```bash1 V, F0 y/ m" v: u' Z. g+ a' {
gyp ERR! find VS
" K2 X# `) a* Y- \4 Z6 ygyp ERR! find VS msvs_version not set from command line or npm config0 A5 W; P& a) X" w8 N
gyp ERR! find VS running in VS Command Prompt, installation path is:7 F; K% q1 u7 a2 Z, d- K
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"; s- g9 F; |& U3 X/ m; e4 c
gyp ERR! find VS - will only use this version) W4 e9 O1 c; p/ b. c  ^
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer1 Y9 L; C' a8 o4 N8 S
gyp ERR! find VS looking for Visual Studio 2015
! w8 G  H# [6 `! x( \8 o: \' ggyp ERR! find VS - not found
) L- O) n$ l: r) _1 [gyp ERR! find VS looking for Visual Studio 2013
! J/ z8 z4 G1 ]: ^$ Egyp ERR! find VS - not found
1 W+ Y7 d( f, \$ Ogyp ERR! find VS* H/ h! Z% C: {; o$ B" W5 X
gyp ERR! find VS **************************************************************
6 e4 n+ c7 z* m% lgyp ERR! find VS You need to install the latest version of Visual Studio
4 `: ^% t4 O" I6 o/ ^gyp ERR! find VS including the "Desktop development with C++" workload.
3 w* H1 v% O% o) S& `' P+ Fgyp ERR! find VS For more information consult the documentation at:4 i. [( }6 g4 m7 E/ I
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
; Z4 U: M# t; p! _$ C9 h6 _gyp ERR! find VS **************************************************************/ U; }+ C- g: [% c% K
gyp ERR! find VS. i( p* a8 E( \9 q, \/ [
gyp ERR! configure error
0 {# x( T% [" s4 v  D' `; i3 C- Bgyp ERR! stack Error: Could not find any Visual Studio installation to use
. W+ }4 X$ j& h$ K4 D4 vgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
; ?3 _2 m2 l; \/ V2 F4 v2 h* O5 Q8 |dio.js:121:47)
! q" C1 g+ I1 B' s; hgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16) W$ ?9 O, \4 l" [# q$ X% h7 p7 y
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16/ p, W& J/ x0 m0 u; `
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
5 k+ c) \% G2 z, Wgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:164 [! |* E  W  }4 t6 y& c( m) w
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
# r( I7 b( {7 B# U. T; Ggyp ERR! stack     at ChildProcess.emit (events.js:315:20): k  W6 r8 K8 C" A, g2 C
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)( a1 q, ]! _6 O* F* X
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)9 i8 b5 f% N' X* I7 M! F6 K( |
gyp ERR! System Windows_NT 10.0.15063

% \( }% e5 R: K
# U# k8 Z) h# ?& a& S- }% n解决办法
3 R4 N& w( ~2 N3 Z0 x) G9 S. O  p1、卸载nodejs重新安装一遍% p8 l' e% p" y0 F% h$ S1 S

4 U# a7 |4 g# q% \2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
- P. `, @" h4 X, a; G2 \5 F
# A7 G2 J# D$ h+ U  Q3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
* B# Y8 n( }7 E# @. F$ P; m! j————————————————. z: W4 x1 C2 G+ a9 R* [
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
3 P: C6 z& t- {  [1 g6 ^2 F; U: d原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

529

回帖

3528

积分

管理员

积分
3528
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
0 W; H# T7 S  Y( t2 Z" t- {8 \. I1 c$ f( m' }/ M% g) g( F0 Q2 _: _+ I& n
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。0 c6 X% u' X3 k' [' m* g
% R: i+ }) B7 J! I' `
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
$ S, ?, k3 f7 P8 g' A+ \; b————————————————
, [. e' U3 A5 \$ \+ k$ t6 g版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
! U, d- f9 w  e4 o7 t1 p& m7 C原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-17 23:26 , Processed in 0.011844 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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