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

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

[复制链接]

340

主题

524

回帖

3508

积分

管理员

积分
3508
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
+ `6 s4 J$ ]; z  K' r. L: M6 G- F
```bash
2 q: N( R# B6 ngyp ERR! find VS6 V8 o+ g" D( L- S$ Y+ {
gyp ERR! find VS msvs_version not set from command line or npm config
8 L4 g4 j6 ~4 d+ `8 J! X/ Xgyp ERR! find VS running in VS Command Prompt, installation path is:- _1 n3 p9 v0 b1 T& J: V
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"  t; O2 u7 l5 u0 c8 ^0 s
gyp ERR! find VS - will only use this version
; Q4 U# {: J0 j: o' g, Q# vgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
5 M4 \1 J$ s9 x7 G9 W% |gyp ERR! find VS looking for Visual Studio 20158 F4 e1 C3 q$ _$ R- j3 s+ D
gyp ERR! find VS - not found+ Z9 |+ h2 {% S1 s* M9 K
gyp ERR! find VS looking for Visual Studio 2013
& B; F4 Y3 o1 u2 H" Z7 J" bgyp ERR! find VS - not found
& \% c5 x. p; E6 g7 b3 ogyp ERR! find VS0 ~7 I- b' _# f3 _7 P. t
gyp ERR! find VS **************************************************************
  u- d2 }: t' ^8 ]" h" lgyp ERR! find VS You need to install the latest version of Visual Studio
3 _) V4 S5 t9 E- ngyp ERR! find VS including the "Desktop development with C++" workload.
0 _$ X; A& Y+ R6 t  Agyp ERR! find VS For more information consult the documentation at:7 a/ y+ I) t! W: ?. V
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
3 X/ r' A- w* ~+ X: N9 e& \9 q: ?3 Xgyp ERR! find VS **************************************************************
0 @8 y+ Z/ Y$ X( Tgyp ERR! find VS  N9 B4 ]8 _  d0 \+ ~! v
gyp ERR! configure error
0 n/ y5 _: y5 Vgyp ERR! stack Error: Could not find any Visual Studio installation to use+ U" D- P: ^8 _  t7 q' N( s+ Q
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu; u' |! V0 ]1 ?. E& }
dio.js:121:47)
4 j' @) W7 O( l- b1 V, h! l) Vgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
0 J1 l! b5 J8 n1 u- E- n& Bgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16# L' `0 m, o: d4 F& r
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
. G) D. Y( O5 Z9 r2 j2 \  Rgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
* L& w( P; o' [gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)2 N# \, f7 b) M' j" A. M4 E
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)" S3 x! X+ {. A4 H
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)2 s* D1 \  B! S8 l, k( Z% N/ V
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
+ v6 @' o6 p7 y% ~gyp ERR! System Windows_NT 10.0.15063
) p/ m, x& C/ P9 O) ^

3 m1 O- [3 o  B7 p% y解决办法
! J  z( d( j5 I  O1、卸载nodejs重新安装一遍/ v/ k1 o$ d1 H6 j. x: q

* l8 ~! C5 S1 t3 |6 l! [2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
7 F2 I, A5 t  L$ l) Y* A! S  {0 E1 h5 W$ z  x+ J
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
/ J) V8 U5 Y9 z# k2 a————————————————0 ]2 z; r7 N! B6 A; }
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
. ?% C' P2 y% I% ?+ f8 s! ~; g原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

524

回帖

3508

积分

管理员

积分
3508
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
6 m% X# R9 d$ B7 Q0 X" b  j9 S# K" d3 v4 h, e2 P. A  ~
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
2 E8 N: e4 a- ^& v( C
. O5 z: Y( _3 B- H- j- i0 z$ h然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
( P% @* ?9 |: {( Z————————————————
) X: D7 N% b( x9 F- m版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
% E) h4 y' P# z( L: g! S( m# g# g原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-14 17:28 , Processed in 0.016386 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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