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

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

[复制链接]

322

主题

485

回帖

3170

积分

管理员

积分
3170
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
+ ^- ^0 \; m! O0 N  @5 d
```bash' g" f/ O  v# t2 R) A' P
gyp ERR! find VS
# D. j0 ?3 J7 K  i8 `( }& M, M) igyp ERR! find VS msvs_version not set from command line or npm config
; |! w7 _! F$ r5 M) ogyp ERR! find VS running in VS Command Prompt, installation path is:
  F3 Q, g1 u# p- Vgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"* T9 d2 {5 E( P" a/ h4 g# [4 S
gyp ERR! find VS - will only use this version, s7 N1 P% T2 X. _) l1 d2 e; t
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer2 N3 \5 c* U& h. w1 g' F  C
gyp ERR! find VS looking for Visual Studio 2015, H* `7 `( }4 G1 s; r7 c. R7 g
gyp ERR! find VS - not found
7 h( Y( G) X3 N( K% Bgyp ERR! find VS looking for Visual Studio 2013
; C0 X6 B1 E4 z, A& |: Egyp ERR! find VS - not found. H/ i+ M0 R  S# t
gyp ERR! find VS
; c( M& `( x; L8 i: ygyp ERR! find VS **************************************************************
! I: H/ y& ?! m- M" [/ x$ D. Dgyp ERR! find VS You need to install the latest version of Visual Studio
( E  K. R( s! xgyp ERR! find VS including the "Desktop development with C++" workload.
8 d. d  k6 w6 F$ I% Mgyp ERR! find VS For more information consult the documentation at:" Y7 [" A0 x: C: r0 `
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
2 T: ]. ~$ O! `, M9 `& X% m' Sgyp ERR! find VS **************************************************************
1 M) ^3 X9 F& Rgyp ERR! find VS
" T1 C$ J9 @% [! j' Hgyp ERR! configure error
' ~6 E7 z, r" t% }* J$ ^0 Mgyp ERR! stack Error: Could not find any Visual Studio installation to use# _8 ?0 ]4 X( j
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu+ p1 H  w* h( V1 s! r! o, L
dio.js:121:47)4 f: |# B, b* B6 y8 P/ j2 h! V7 u3 x+ t
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16$ j  x2 }4 [. k6 n( L
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:165 m4 T7 P: ^, `! x$ e4 Y  [
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
5 |' O  @; i+ X/ P4 x; {' i9 Q5 |gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:167 v+ Q3 b# O; W: x  o
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
7 ^. x* W, i/ pgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
2 [3 X) b6 K$ _! p1 zgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
8 N  h% E* g. j4 d# ]0 `  xgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)/ v! J8 v1 f9 n
gyp ERR! System Windows_NT 10.0.15063

$ U4 b  P/ I2 p% D7 `7 F6 d3 F8 G* [
* C  f& F' I% n- y! x  W" N# s解决办法4 }: p$ g5 u: ], c% u
1、卸载nodejs重新安装一遍0 u9 O; Y% D+ Y2 a, q9 z; S

8 a% Y1 v8 Q, W. c) g2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org% @( v! ]" f* L. A& P1 `5 q3 A
* X: x3 F* i" d
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
+ H* S9 A8 i- T$ W& ^————————————————3 W* f  z& j6 K) X$ A
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
6 n! Q; {! I" a9 e& F原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

322

主题

485

回帖

3170

积分

管理员

积分
3170
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.76 \- W6 \" ?8 J2 H( r! R6 r; G

% K9 y" M7 Q9 D, R6 f2 ]6 p由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
% S- P. U) }# m5 O0 [
$ k) x: a% f+ M+ v7 l' z- `然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!" U" k2 R. B" p+ Y8 H* C
————————————————" J' M! P3 M& N2 r& v2 l. ?* s' e
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。3 n, Z9 ~# O1 B6 K
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-16 12:27 , Processed in 0.092547 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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