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

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

[复制链接]

341

主题

543

回帖

3579

积分

管理员

积分
3579
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
* I' {/ C% M$ V% [( Y2 Y5 m4 e
```bash
! A1 h2 m5 v/ \9 z# h7 d% cgyp ERR! find VS+ ^, Q1 C/ z9 `9 E7 I
gyp ERR! find VS msvs_version not set from command line or npm config7 v, t$ Q7 J) ?7 Z
gyp ERR! find VS running in VS Command Prompt, installation path is:( {1 ~" j: J- i" O
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
8 |0 y9 S5 T7 |$ P. B% |gyp ERR! find VS - will only use this version+ R8 [6 Z7 A7 e1 B: D" H
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
4 {; J/ K# U; [2 _5 mgyp ERR! find VS looking for Visual Studio 2015
2 w' J0 G" m8 G5 @gyp ERR! find VS - not found
/ \" g4 `! i. W: F+ V" i) P9 @# }gyp ERR! find VS looking for Visual Studio 2013" G) x5 G$ D' R
gyp ERR! find VS - not found' h0 I! W5 N8 |# H/ j
gyp ERR! find VS
5 f/ _: q/ {9 j: _" y7 dgyp ERR! find VS **************************************************************
( y$ {$ a8 |7 u7 v% a" hgyp ERR! find VS You need to install the latest version of Visual Studio
$ V1 T, A8 S& C) x- x& e* |" Ggyp ERR! find VS including the "Desktop development with C++" workload.2 J1 E1 f* H6 b; w: B7 K* a
gyp ERR! find VS For more information consult the documentation at:' X! E; g1 s- V+ U! v: a0 s# a
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows0 E6 X2 m. Q$ V& y: i9 a
gyp ERR! find VS **************************************************************2 w# o( B' N" {+ \: Y& ^, e% ?
gyp ERR! find VS
) }1 g- e$ q8 Y0 |- A; Mgyp ERR! configure error
6 h/ F: T) R) e* Tgyp ERR! stack Error: Could not find any Visual Studio installation to use
0 u8 L; C; K5 ~; j3 K4 Igyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu5 \5 ^/ c: c$ E) ~; Q9 G- f
dio.js:121:47)2 m! E* y, ~  {% B- d/ B
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
0 h- Z9 n4 @" G8 ~6 [! rgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
7 R2 D0 x% n' @7 i# O! u2 f/ dgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
9 U7 T0 ?4 k4 {  ?' C/ z( k" Igyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16  [4 u% K6 ~+ q3 a
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)5 f5 P8 Y8 I1 d' `3 U% r6 ?
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
  p9 ~* C/ }9 W9 Y. X% h( dgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)7 M7 g3 B, s+ K
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
& N0 l4 R8 y9 ^$ s* e* e) ]4 dgyp ERR! System Windows_NT 10.0.15063
% ]7 I- B% ~8 Y; U% F

' Q7 v8 @$ O" N$ j3 h9 I解决办法" g' q4 ~) E& J8 _2 R: `( ]
1、卸载nodejs重新安装一遍0 g' R6 `- _; w( [$ O$ l

4 G/ v; N- ?% x0 A2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
$ J% r% y* g. ^3 T7 m6 t/ U; v
2 F, o0 d7 O* Q2 w2 Y3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools) s9 I: h0 d0 o8 W! v+ y0 y
————————————————
5 T$ A7 R" W* d$ |) i* ?1 [1 o; E版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
) p1 u) [6 Y; D, m  m8 K原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

341

主题

543

回帖

3579

积分

管理员

积分
3579
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
% L$ n% y& N' ~/ y% G5 N1 B- J+ q+ \2 P$ m8 l. L/ C
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
, u+ a% w8 f) F  K: d( c
! L. o+ A' G( x然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
- k+ @# n1 X; ]2 }: d# c————————————————- M4 D9 f. c2 q* N# c5 B
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
# @5 c& X) d3 e8 n7 y4 \原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-26 18:21 , Processed in 0.015253 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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