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

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

[复制链接]

340

主题

522

回帖

3494

积分

管理员

积分
3494
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:- f' _$ z8 M( X+ u# s+ C* I
```bash/ E0 E- i) d2 p( v, @/ ~3 E5 J
gyp ERR! find VS
9 x% i8 k, D2 G) |gyp ERR! find VS msvs_version not set from command line or npm config
0 J# G7 ~) o0 ngyp ERR! find VS running in VS Command Prompt, installation path is:
# E0 t, k2 K7 j; ~1 j+ dgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
, A+ y* c9 i) d' n9 P5 Wgyp ERR! find VS - will only use this version) j5 R" x$ C$ D* C; n# T! N) h
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer8 ^  b4 R. w2 M7 `" i
gyp ERR! find VS looking for Visual Studio 2015
6 s, @# Z& ?" \/ Egyp ERR! find VS - not found
8 ?! F8 ?: }* N4 bgyp ERR! find VS looking for Visual Studio 2013
( c# a. D1 ~+ }  agyp ERR! find VS - not found2 t" O! d' p& D6 ^) j0 @$ g
gyp ERR! find VS/ g+ C6 K. `. ~- x
gyp ERR! find VS **************************************************************
% s. K  Y9 l$ H& E) p% b1 ugyp ERR! find VS You need to install the latest version of Visual Studio* K4 o1 i7 _% x$ G
gyp ERR! find VS including the "Desktop development with C++" workload.
$ h5 p. Z. v, N  s( o' ugyp ERR! find VS For more information consult the documentation at:; n$ U: Z7 v" c8 b
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows, _! r2 P  M& Q1 l- V& o
gyp ERR! find VS **************************************************************5 E/ d9 d: p2 B3 T0 [; G3 ]
gyp ERR! find VS( I1 L- R) z- v/ ^3 w8 t% h
gyp ERR! configure error
! h" Y$ d; C; d+ Vgyp ERR! stack Error: Could not find any Visual Studio installation to use# s! m& D+ v' X9 c
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
) T5 \" ~8 d8 L6 j; K" ]dio.js:121:47)1 M+ m+ M! ^. \
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
. P" J2 b/ K8 vgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16* [* o* P% S$ \
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7" Z4 `5 A& Z3 C+ Q* R
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
- ^- ]& C5 }$ H$ hgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
* u# O8 I6 C, j( M% K. mgyp ERR! stack     at ChildProcess.emit (events.js:315:20): Y0 [4 u; K: o( H6 T
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
1 v5 H1 B  j6 n* J% Y+ h) Fgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
( i' q1 I9 i8 q- [( Tgyp ERR! System Windows_NT 10.0.15063
7 c8 |3 a8 f( j' h

- m3 F  M- ?3 a- n解决办法# ^: N; E0 P2 h( f7 ]
1、卸载nodejs重新安装一遍
' b5 k6 f2 x" r7 Z: H( I, {
5 r) o+ m# w2 f6 p8 T8 J% w2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
; u* n0 Z# r! b/ [0 G, {5 x  a4 j# T0 P$ y* i6 s7 W& e5 s
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools* r3 V1 X' |' j4 D
————————————————& J& `/ U; P& K- F, i  @% s
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
- H* h2 N: K% ^5 G1 U. s% i; i) C, I原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

522

回帖

3494

积分

管理员

积分
3494
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
: r2 j5 c8 w9 c4 V' ?* Y/ a- I
  o# C% M& j/ K9 _1 U) B5 B由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。' G$ {7 I$ F2 U/ a8 Y

  L# `1 h3 B" [& o+ o: p7 S然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!' n4 u, ^2 E; _3 w2 Q( i2 c: }6 ?1 Q% X
————————————————8 h( c9 n7 S) k9 z. t
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
4 E8 n1 U7 U- ?) r原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-12 15:44 , Processed in 0.023954 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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