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

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

[复制链接]

524

主题

676

回帖

4597

积分

管理员

积分
4597
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
4 m* u# @$ k" v) |5 }/ k
```bash
' Q- J! s8 _0 jgyp ERR! find VS" T& i( }# Z  ~" E! B& C9 l
gyp ERR! find VS msvs_version not set from command line or npm config, O. S& Z# k0 w, A
gyp ERR! find VS running in VS Command Prompt, installation path is:
, H5 _7 v! f2 ^gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017". q3 ~. m' O0 S) r; u$ n
gyp ERR! find VS - will only use this version+ ?8 J/ I1 w* c* Y5 `% W& @1 c
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer1 y" c$ U& E8 f0 X
gyp ERR! find VS looking for Visual Studio 2015
/ t5 z7 G6 _+ s9 Egyp ERR! find VS - not found0 g& v" |" w( h8 A! D" M6 N2 `
gyp ERR! find VS looking for Visual Studio 2013% x4 `/ Y; U2 i# O
gyp ERR! find VS - not found
: @( e# P$ U4 v8 _4 b% `gyp ERR! find VS, ?8 S8 o' v) F$ S  d* t( J  }
gyp ERR! find VS **************************************************************
, O7 v+ q: c& J. _% q4 T8 L5 Wgyp ERR! find VS You need to install the latest version of Visual Studio- w( [7 \$ k0 M: A
gyp ERR! find VS including the "Desktop development with C++" workload." A$ T) v: q5 ^( u3 Y! {% m0 u5 q$ ~0 z
gyp ERR! find VS For more information consult the documentation at:" |8 e4 T" o6 O, {) X( ~, c
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows5 b' A: e  q# j: y
gyp ERR! find VS **************************************************************
+ s' G5 V5 x4 sgyp ERR! find VS
2 e6 K  p' Y2 {3 f/ wgyp ERR! configure error
9 t% ~# G8 u- I# `gyp ERR! stack Error: Could not find any Visual Studio installation to use1 h2 x. C: E& ?& R# T/ T$ }7 X& p
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu$ |: E% b5 F" {( W  l
dio.js:121:47)/ _  L/ U  l' h+ ^2 o
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16" h/ l( ?; D  c
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
7 e/ J) P) V2 j2 o+ i# U4 o, O  ^gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
4 o+ x8 ]' o. y5 ^7 I1 r+ ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16# c. E3 B: Z; |0 u; J9 T; L% W
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5); I! n5 I9 p2 h' _- }" _8 T6 ]: p
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)# e  E# p) }6 A5 d+ [3 D
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)( W- m  I. y( k7 V: P
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)( C, q  r5 B& D' O' {3 m
gyp ERR! System Windows_NT 10.0.15063

3 I+ B% Z# @5 z. L
+ S* O0 }& X4 j& q6 E% _解决办法0 C7 b* p+ b2 p- F) [
1、卸载nodejs重新安装一遍, |) ?- M( m! |, q0 L8 J% C# v
& {9 T+ n- n( G
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org# G) Z2 F; l; D$ k- p

$ E# G3 w3 F, Q  b. U. d3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
1 b# g8 m5 V+ h/ \4 S: K5 F————————————————3 l2 m% J" h1 Z( Y% M3 K- U
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。, }" Y' K/ o6 B) [: @3 k" e0 A
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
欢迎定制:13928122889
回复

使用道具 举报

524

主题

676

回帖

4597

积分

管理员

积分
4597
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
5 X( C. @# K0 o7 H7 _! {5 e- R: Z
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
2 H$ r: ^& U0 e+ F8 j: {0 M) @# x% [0 b: O
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
4 k2 H- ]2 ?" B* @0 y  m2 W————————————————3 [8 i* c3 U. d. `7 S) d
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
  i9 O1 n: J& a4 N7 z. e0 H原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
欢迎定制:13928122889
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-18 21:15 , Processed in 0.016514 second(s), 3 queries , Redis On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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