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

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

[复制链接]

320

主题

485

回帖

3140

积分

管理员

积分
3140
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:* k9 T; m# B' w9 m/ q5 N" K# @
```bash* f4 ^  \8 |# [8 r; j
gyp ERR! find VS- E, c2 W2 B# O
gyp ERR! find VS msvs_version not set from command line or npm config
  Q, [8 O0 j$ o3 u; Zgyp ERR! find VS running in VS Command Prompt, installation path is:' }, t$ x) W& a5 o0 n7 C; b
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"* S) {9 ^+ _6 \2 Q8 R
gyp ERR! find VS - will only use this version
( v: I+ p8 t. B3 d" Y  Cgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer) Y5 P' O+ O3 f! I- c1 A) R
gyp ERR! find VS looking for Visual Studio 20152 ]# y# ~. j8 _
gyp ERR! find VS - not found" i' R+ a4 b* @, M
gyp ERR! find VS looking for Visual Studio 2013
& m4 i' u" U6 m) V4 rgyp ERR! find VS - not found: L$ q! Q1 A5 a
gyp ERR! find VS
9 c1 J, `& [. b1 T/ ugyp ERR! find VS **************************************************************
) A! v, x3 ~* g" _1 ?5 y, rgyp ERR! find VS You need to install the latest version of Visual Studio4 C% X6 D& j0 G
gyp ERR! find VS including the "Desktop development with C++" workload.! q- ~! N1 O" J9 ?" r; p) H
gyp ERR! find VS For more information consult the documentation at:3 E+ C3 ~- f! t- V. m
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows% c* e/ s5 E/ Q$ u$ O
gyp ERR! find VS **************************************************************+ ?6 z: L/ a4 P7 L. t0 _! e
gyp ERR! find VS. Z% S8 F* K! l. `1 r
gyp ERR! configure error
+ D9 g" H$ d7 ~- V: ygyp ERR! stack Error: Could not find any Visual Studio installation to use( A5 A  v2 [; m3 K3 [: Y+ f& h
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
$ L4 c1 q/ z/ R2 C" B2 i8 `" v$ K2 |dio.js:121:47)
# X$ e; _  [: v9 {# `4 ngyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16! o- B2 u8 `9 g* I! G1 ?0 K
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:167 B, p1 N$ F$ w- G9 w
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
& H2 l+ W  J( e2 O6 igyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16/ b, V4 C& L0 d+ n1 j
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)3 S5 x$ S3 F7 \% g/ R& |
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
6 V0 g- L- b& C$ x& C# ogyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
7 u6 O* P1 e# ngyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
2 _! @! E) d0 g' hgyp ERR! System Windows_NT 10.0.15063

; P( @& r% ~8 j' y: p
$ ?& T# M% `; @( F5 V解决办法
  t  w. T: _. h5 L1、卸载nodejs重新安装一遍
6 w/ d% m; r; R; j+ Y$ ]: k' S. S* Y" q( [4 @0 c4 X9 U
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
* ^- x4 F" @  g1 g7 W
6 x- k' a9 P9 `! n3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools8 U# B+ t' [& q' J5 S6 Q: E- v
————————————————# b$ x5 Y4 P- V
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
. E! L! c7 n1 A% O4 f+ A" A7 _原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

320

主题

485

回帖

3140

积分

管理员

积分
3140
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7, \" s$ k6 B, m5 y7 e
) Y1 O) e2 C3 U6 x' y  ^
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。. S$ @: E$ Z" Q  L# s
  O9 H9 [& V3 Q0 j
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!0 |' l( W* M: X
————————————————
# E( n2 i# Y/ V0 t版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
3 r; J4 E" k6 d: b  }原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|通达产控投资 ( 粤ICP备2023021749号-1|粤公网安备 44030402006137号 )

GMT+8, 2025-8-19 13:56 , Processed in 0.078008 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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