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

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

[复制链接]

331

主题

511

回帖

3351

积分

管理员

积分
3351
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
# P% i2 i; F! i
```bash
/ ^3 ^3 B6 d  H" o) n( zgyp ERR! find VS, v. u1 G1 M. F( s  |
gyp ERR! find VS msvs_version not set from command line or npm config
5 y! O: f. R/ g; S* V" z6 a0 [gyp ERR! find VS running in VS Command Prompt, installation path is:
' ^# X7 d9 N) u2 n# j" J: u8 ~gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
0 Y0 n, U7 [8 x$ {6 Mgyp ERR! find VS - will only use this version
# G. U! B% N8 Z* C/ U- Wgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer; M9 b. K( G3 }0 ?% ~
gyp ERR! find VS looking for Visual Studio 2015/ P% a7 K4 r; y- Z
gyp ERR! find VS - not found
8 i* E% O! u/ w2 d1 e& P: Fgyp ERR! find VS looking for Visual Studio 2013" F: ^& V, Z: M
gyp ERR! find VS - not found
: Y( ?! z: a3 N, r1 I! g& Hgyp ERR! find VS) m( t" K- T) D! s0 J7 c  ~
gyp ERR! find VS **************************************************************2 B$ ]% U& R  V/ H" e
gyp ERR! find VS You need to install the latest version of Visual Studio
: M' z! Z* K# d7 Egyp ERR! find VS including the "Desktop development with C++" workload.  a/ B* G, w' w  D6 h
gyp ERR! find VS For more information consult the documentation at:
# g- M) B, }1 o3 d, H* sgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
/ Q- V. I& p" ~0 q3 qgyp ERR! find VS **************************************************************  a% e6 _; N( J4 }3 s8 N
gyp ERR! find VS
1 Q5 T' d0 e) f$ dgyp ERR! configure error
1 y& o( R3 D$ I, ^6 Tgyp ERR! stack Error: Could not find any Visual Studio installation to use
/ l/ n5 _/ P  c+ J. [' agyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu" H8 B0 d4 w3 T1 K# z3 N+ J
dio.js:121:47)% M6 i6 p0 q/ m: a6 {$ S  |
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16- S( j9 V$ {# E( q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
% Q1 s: h* j  ~4 b5 S% Tgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7$ s+ ~& z  [: ^( C1 U* @
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
! }1 [! z9 C# t  j- }7 K6 u4 Ogyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
" ]: ?4 Q! t5 K4 t" a$ Q' O) Bgyp ERR! stack     at ChildProcess.emit (events.js:315:20)8 g9 b" v- r5 w9 V, a5 W+ _/ F( F
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
( ~7 G  Y( W( ~. ]+ t& z- f8 B- i- ~gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
- t# U+ W' l3 F/ ]7 Ogyp ERR! System Windows_NT 10.0.15063
2 N3 W6 Q, N" r- `2 R# m+ N

8 f. R! A& p: \7 I, q解决办法
+ A: N: p( u, b1、卸载nodejs重新安装一遍
, O) P8 [/ K4 m7 x5 m! f/ S$ t) M+ x; e9 [
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org! L: `4 t6 A5 Y: N" r
9 {. a0 ^8 s) b# G1 h& ^
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
$ T" k' f7 a% k1 L) M( }. g————————————————
1 U4 k2 r/ U# N% ^4 O7 [. ~版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。0 M% @0 b8 w# T2 N
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

331

主题

511

回帖

3351

积分

管理员

积分
3351
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
) G8 v! e0 T4 C1 f, i8 w# N7 J8 n; ]+ A
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。8 g2 F/ B0 e! z
4 [" J1 E" h# O8 m# A
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
% v" x$ s3 q! g————————————————7 H" @8 x1 h) a
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。( F6 ~, A3 t* M1 l$ w5 B
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-19 03:12 , Processed in 0.067998 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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