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

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

[复制链接]

340

主题

524

回帖

3508

积分

管理员

积分
3508
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
, L) q# m7 }. w- j& r& E2 v
```bash
, w9 a+ A) q6 n$ a4 X( Ogyp ERR! find VS1 Y, q' O, H/ u5 y+ T* S* T
gyp ERR! find VS msvs_version not set from command line or npm config
: G) O7 r. x- E) m' F; ]# T# S) Bgyp ERR! find VS running in VS Command Prompt, installation path is:0 c7 P- J$ [2 n
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"% S7 A1 X3 w2 a7 J) x
gyp ERR! find VS - will only use this version
1 \. S$ T' A# @, mgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer( {% k/ x2 t' A, S% a
gyp ERR! find VS looking for Visual Studio 2015
& d# W: c' x! S" t; Mgyp ERR! find VS - not found
9 e, \% M2 g2 U2 {9 lgyp ERR! find VS looking for Visual Studio 20130 Y  U$ k( s9 P  I: w
gyp ERR! find VS - not found
/ _% w0 l! ?2 V9 K: t# z6 Ygyp ERR! find VS# S4 B6 V, M/ j8 b
gyp ERR! find VS **************************************************************
, G+ E2 m( t, R4 f0 @6 R9 }: [gyp ERR! find VS You need to install the latest version of Visual Studio1 w9 C# p0 j' ?; N( F. ]# z' P
gyp ERR! find VS including the "Desktop development with C++" workload.
( [( N( K( C* q- ~+ a) Ugyp ERR! find VS For more information consult the documentation at:+ z6 X% T, o/ i2 c: E& s0 B1 V
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows5 q8 V) B. `- x+ X! p9 k) ~  v
gyp ERR! find VS **************************************************************
) E- Y4 Z- J8 m, w  i7 n( r- O4 ngyp ERR! find VS9 a( H, [/ T: n- A9 T
gyp ERR! configure error1 v9 P  x) a; A( S
gyp ERR! stack Error: Could not find any Visual Studio installation to use7 H/ d+ S0 L! q( M7 }
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
: V& H0 B# E( S* }; J  udio.js:121:47); u0 P4 H, m* L! R$ F5 x9 H% v
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:162 G# v; l- `: i: f1 W* k- s( S. c
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
# V* I. }. f+ s: z7 F( b; |gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7+ ]+ w7 E* y3 S3 o  `* G7 T
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16# U: B; y& U( O* C
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)* \. m# n" o4 r  E( T( N% h5 p  X
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)# _3 f7 F+ A6 F0 ~
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)" a+ M; Y6 Y% z8 a) d
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)$ R" a) A- m% Q! E% Y8 `6 n4 Y
gyp ERR! System Windows_NT 10.0.15063
5 d& Q' ~! e% V# t8 Z9 v
5 j5 }5 O$ }( U4 ?" P4 T
解决办法
& m7 Y& s! I. u6 G3 \1、卸载nodejs重新安装一遍% c" w7 O  F2 A& ]0 Y, O: I

4 Z1 N: h2 p7 G4 W! s: J' V2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org% T7 r- l# n2 p% y
5 R9 B# z, I+ k, o4 k+ q  ~
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
$ k# Q4 W! g, Z, S/ i) j- e, ]$ ?: M————————————————
; Z" L# Q6 S/ i. ^4 }2 f版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。6 P% r& v$ I! _/ \$ L2 h# N
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

524

回帖

3508

积分

管理员

积分
3508
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
5 A3 G0 Y2 R( T. g( }
' i5 ^& Q1 l# x+ b6 V1 m% X2 ~由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。8 Q# v9 j0 }; W1 k* R
0 T  [' V4 X8 @0 l* r
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
  S# F5 ?: V3 z/ a5 H) }5 N0 c————————————————' ~) F9 Y  O9 k  T+ x: z  K
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。, O# f3 u) J) e, e8 h7 R/ Q
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-14 19:08 , Processed in 0.023936 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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