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

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

[复制链接]

347

主题

565

回帖

3685

积分

管理员

积分
3685
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:0 b1 ~% y* @9 O6 g! c! n. ?7 y
```bash: q5 Y9 @/ W) F8 O8 O
gyp ERR! find VS, O1 s( q( f# ~9 g4 t( I, Y% U- S, B
gyp ERR! find VS msvs_version not set from command line or npm config
3 E  y- M$ H* ~8 f5 Y+ Jgyp ERR! find VS running in VS Command Prompt, installation path is:7 e: h) ^! c% f' T( K4 H9 e! j
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"( V1 ]" I# Y: c9 \. M
gyp ERR! find VS - will only use this version, B- j  c9 s: J: f
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer% i9 D' u# C  x5 h! j4 c
gyp ERR! find VS looking for Visual Studio 2015
: z! V+ w  K2 N$ A; }gyp ERR! find VS - not found
$ x& t5 `9 J8 e+ ?gyp ERR! find VS looking for Visual Studio 2013
, U( i) C' G8 C$ U# y8 ygyp ERR! find VS - not found
3 W9 J) H! U" {8 J. v! Q5 Fgyp ERR! find VS+ a# D' |: r3 S: \
gyp ERR! find VS **************************************************************
: |0 P, s1 g) L/ X% B! T8 vgyp ERR! find VS You need to install the latest version of Visual Studio3 w& D) `+ p' l3 Y5 B/ z
gyp ERR! find VS including the "Desktop development with C++" workload.
- J' C2 G! e, @+ [/ Egyp ERR! find VS For more information consult the documentation at:
4 Q6 ^$ K* P+ z6 p' u: M7 Tgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
8 I" y) B$ ^. d+ Z, ?& v$ hgyp ERR! find VS **************************************************************) D) L/ q8 i  w$ A
gyp ERR! find VS1 z# C- a- |2 W* N: q8 e; w, `
gyp ERR! configure error& ~4 O2 s$ L5 B5 U/ h' i
gyp ERR! stack Error: Could not find any Visual Studio installation to use1 Q- L" a9 E( P" W( }
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
5 Z1 f! V1 Q8 n9 @dio.js:121:47)
( d, @) c& Q+ O) {- _" l+ y5 lgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
  @$ M- `# R/ I* u! o2 Y4 [gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16# f* ?: N1 `) p$ W2 K* M
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
# V. O& [* {, U/ w8 o% wgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
* c4 s# r! D* w. Y; [+ L' ]+ u. `. dgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
; V5 r1 I% d) R( Sgyp ERR! stack     at ChildProcess.emit (events.js:315:20)( y5 v3 \7 ?# {9 W5 w/ ]9 \" m4 v1 v- Y
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
1 d) q$ m: r6 U3 a2 y4 {gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)# }5 Y6 Z/ ~: w, `' a& r4 f
gyp ERR! System Windows_NT 10.0.15063

7 {1 [( |0 |, v: p, N: K/ a  F0 P4 G7 i
解决办法4 @: M( D  J' m
1、卸载nodejs重新安装一遍& c& f4 D$ L! R

) d" n% m6 G5 q# T3 Y( J2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org+ v7 X2 {( V+ T! l" D
! l5 U1 O) C0 s3 N
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
6 D- E( m( }  j' _8 P- H————————————————  W! m/ d1 y0 }* }
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
2 I  ?, v, u- Z) I9 C原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

565

回帖

3685

积分

管理员

积分
3685
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
6 U# `( P% Y8 ]+ _/ D1 \" w* C" `- l) s  z  U, ?
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。7 f: N; i9 b" M$ p6 F8 R5 k) J

6 Z( @/ b) k( \: A然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
9 @6 P  ]. c, f0 Y% G9 D+ y————————————————8 J2 Z* ?6 Y2 T! B. e
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。. C1 j5 d5 S+ e7 B# Q0 b  c* ]: U9 F1 D
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-18 08:24 , Processed in 0.013146 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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