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

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

[复制链接]

340

主题

529

回帖

3532

积分

管理员

积分
3532
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:7 m, S7 s- d- u) d  x
```bash5 H+ l$ B# z5 J
gyp ERR! find VS3 O$ Y' q$ z* C$ K" ]
gyp ERR! find VS msvs_version not set from command line or npm config. q7 Q3 R& y* I& o% |0 |) V
gyp ERR! find VS running in VS Command Prompt, installation path is:  w9 h& y  k$ o& F9 t
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"/ j1 @1 c* e; v+ u2 \5 X
gyp ERR! find VS - will only use this version
# v. ]# G( ~; H$ d8 dgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer" G+ W9 y' }' f% d6 i
gyp ERR! find VS looking for Visual Studio 2015
+ ?9 C. {, I9 v4 egyp ERR! find VS - not found* ~% [; Y7 @. N$ q! ^
gyp ERR! find VS looking for Visual Studio 2013) q! Q4 g% S% {5 m1 \4 i4 L
gyp ERR! find VS - not found: x- R' x) X0 y; O
gyp ERR! find VS/ G3 _7 R  U) ?" K1 f* r( j% s
gyp ERR! find VS **************************************************************
3 D9 S0 U1 h' e3 L1 ^gyp ERR! find VS You need to install the latest version of Visual Studio
% E) W5 U0 p" }6 B& Cgyp ERR! find VS including the "Desktop development with C++" workload.
: }* \8 A: f: s! Ggyp ERR! find VS For more information consult the documentation at:
5 L0 f0 h0 S; n* M+ wgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
% v8 Z3 h( o. v; [1 y# jgyp ERR! find VS **************************************************************
: k9 Y+ `& Q/ a0 u5 r* m+ ]; w, F5 Q- Ogyp ERR! find VS) e! Y( O# F% B; i& J
gyp ERR! configure error
. h" B4 ?1 I" O! t! kgyp ERR! stack Error: Could not find any Visual Studio installation to use
  \' `- K) G2 a  u0 n+ {gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
% _' I) ?* D4 E' r, }* x8 `6 Y* L: ^: V. ddio.js:121:47)
4 S* f. `7 Q0 xgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16& d  n" Y& N) Q: X# B
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16( e( L& B1 ?7 C7 e1 ~' a
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7( [, s: o8 U! J6 U; r5 \. x9 m
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
/ o1 [$ k8 M" I( pgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
* Q7 m7 G- R9 d" |- i2 j$ x: fgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
" z9 E& k# }  E' ^- W: ^gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)/ ]6 q+ E  k' z3 n% n
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
+ c, v4 i7 r9 n+ z  p8 Tgyp ERR! System Windows_NT 10.0.15063

: Q- g, h# e+ S1 x) i7 d6 ?6 S# w3 L/ G& r- C' S
解决办法- ^, ?% h8 P" Q' Y1 l- \/ C
1、卸载nodejs重新安装一遍' l$ D6 g0 {6 b  B& a! I

9 Z5 u. F8 c3 N3 y9 }# f2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org$ y, \2 Z7 i( X+ b
7 }' }* H7 e# ~4 l& x% @1 n: s
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools2 X! Q; Z3 W4 J& @
————————————————% p' z6 d, B9 a: a9 l
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
+ Z3 j" s, `* J% g0 E5 Q原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

529

回帖

3532

积分

管理员

积分
3532
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.76 u( P5 C! U  S: o0 H) V
+ v, h0 J8 Y" x' j$ N" a
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。; r, i# s& S* i
8 L% b4 R( ^  r
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
. T# b9 r5 N/ A9 x* g- |————————————————
! B" l5 v. _  a" i" ]6 h版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。" x* p: K; v; t, G, u+ R  L5 l
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-20 05:40 , Processed in 0.022712 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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