找回密码
 立即注册
查看: 1543|回复: 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 | 显示全部楼层 |阅读模式
报错信息:
1 O  t0 i  p/ B4 c$ Q4 I  Y/ g
```bash1 E1 e& z3 K$ |0 D6 P$ ]; N
gyp ERR! find VS/ g; J5 C% f7 ?6 Y0 m
gyp ERR! find VS msvs_version not set from command line or npm config
; a. {$ N5 t# X  @9 Hgyp ERR! find VS running in VS Command Prompt, installation path is:( V8 j6 F( ?" V* f" O0 R: E
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
3 L" [' b6 m8 I! \3 rgyp ERR! find VS - will only use this version
8 t( n5 k) ^( Z  ]6 wgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer% y' w# t: v& {0 _
gyp ERR! find VS looking for Visual Studio 20158 \, Q( U; z0 _7 t' v4 B, K
gyp ERR! find VS - not found
& i' m& x7 P% A! g) E* o+ a4 C# kgyp ERR! find VS looking for Visual Studio 2013. P0 m- ~- U+ d( X
gyp ERR! find VS - not found/ K6 h9 J2 c- g- U, H% k& @
gyp ERR! find VS
! e" E4 l2 |% k8 `gyp ERR! find VS **************************************************************  M6 @) b1 M$ d* r$ L  z! c
gyp ERR! find VS You need to install the latest version of Visual Studio
, j4 q& I1 `: V7 S. C5 ~1 Q% f9 cgyp ERR! find VS including the "Desktop development with C++" workload.1 b- b8 v: b) W5 y$ h
gyp ERR! find VS For more information consult the documentation at:3 [/ u! x1 R& Q: U$ {- @, B
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows+ \) {' }) `7 z8 `) n. I6 S
gyp ERR! find VS **************************************************************
8 @/ O, w+ ]# G7 _' k0 agyp ERR! find VS
( Y1 M1 s8 k  ~gyp ERR! configure error% W* C5 J7 `* E0 \$ t8 |/ i
gyp ERR! stack Error: Could not find any Visual Studio installation to use
5 ]0 p) Z7 @2 ~# }7 Ngyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu8 ^  C. `6 i* t8 z* _* |+ a: ~/ d
dio.js:121:47)3 d# o6 ?3 S( U9 |3 s+ m6 |# _
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
% E, D  O2 J' S+ }: qgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:163 Z  s# q% |) z
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
! W9 Q4 Z% K0 J0 P2 Egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:163 G! n  @; i3 K3 a0 g! u. x
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
+ c3 F" |) Y" ?/ rgyp ERR! stack     at ChildProcess.emit (events.js:315:20)" h' F. n; Y! y3 k4 S: L
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)4 }1 _; _3 v3 H% T
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)1 ~! n, K# W& o# b2 s
gyp ERR! System Windows_NT 10.0.15063
( J- b( u8 k) \+ o: f- z) {" h
7 {8 \0 ]: n4 |4 P) Z5 j: T( S6 b
解决办法
2 f  S* c$ z- c1 t( r# H1、卸载nodejs重新安装一遍
: U# B; N$ d' r$ R" E: _
2 U- T6 s- r) w0 z5 b+ w0 T4 B2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org, k8 w- O, e: h( i
7 u' T% B- |# v
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
% q' [# S7 o/ G% S- ~————————————————+ n$ y' t  c0 p1 l! p0 F, o
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。9 q# o: ~7 l3 P; ~2 G% f
原文链接: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
5 X' k4 x" H9 ^% p
1 b: w+ b6 T: q( g# l由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。  B& W2 M, J* p( j6 {5 w& r/ j* ?
" y, \" E6 f! n* M/ k: C9 E* ]
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
/ l2 @, o5 z. e$ A7 l————————————————
5 [( o+ ^6 _4 \" G版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。; w% h: M' o1 m$ S! L6 }
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-16 23:48 , Processed in 0.013151 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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