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

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

[复制链接]

338

主题

520

回帖

3460

积分

管理员

积分
3460
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
- k# F# R3 k4 O  D5 n
```bash
8 y! H0 y+ J- T$ Mgyp ERR! find VS. U  v0 i' M) T0 y) X6 }  q4 s
gyp ERR! find VS msvs_version not set from command line or npm config# j1 ]6 g0 i: f5 P/ C! B
gyp ERR! find VS running in VS Command Prompt, installation path is:
4 k+ }1 V3 n/ X0 o( Vgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017". w3 L4 b) T; I  ^( N; m
gyp ERR! find VS - will only use this version  |9 w0 P9 W2 u% g) m
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
8 R3 t5 l' x+ m* [- p  Zgyp ERR! find VS looking for Visual Studio 2015! J. [4 H% W# s! t
gyp ERR! find VS - not found
" X& P' E2 k' Y' p  bgyp ERR! find VS looking for Visual Studio 2013
+ n- ?2 I5 X2 u- q, |1 P. Dgyp ERR! find VS - not found6 Y9 Z" A9 b: K$ O
gyp ERR! find VS' `: |2 G5 G; l0 A% C
gyp ERR! find VS **************************************************************
0 A( c. s6 L. t; }' G; _2 Tgyp ERR! find VS You need to install the latest version of Visual Studio
: P' _) ?7 ^/ b7 @gyp ERR! find VS including the "Desktop development with C++" workload.; x; T+ U+ j8 J
gyp ERR! find VS For more information consult the documentation at:2 d0 {; l- u# `$ V7 Z/ m
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
. B5 V' U# {+ bgyp ERR! find VS **************************************************************
$ n: h# r1 \' W, q; zgyp ERR! find VS/ z1 H& c9 \7 _2 Y4 s, r
gyp ERR! configure error
5 H+ V* |" Y8 U( E; hgyp ERR! stack Error: Could not find any Visual Studio installation to use  O" U8 t$ m1 u5 I$ t
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu( |8 p  @) a) ]6 {5 U( r/ M* _
dio.js:121:47)
! J+ B3 y* H7 p/ n6 a; igyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
; s$ \- J( Z5 }( C* ~gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:168 i+ S) }# Z2 U) J
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
4 S* U# G: O6 egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16  U/ B1 `2 W6 O; p) k$ J4 d
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
# h5 R9 `  e, Sgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
3 s, p* _" A/ A- d2 `9 qgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
/ k( G7 Q1 m' G: V& Wgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
6 d1 U  N  s6 h, ~2 t8 H+ Fgyp ERR! System Windows_NT 10.0.15063
1 D$ y+ W: M6 |0 o4 R' t5 P1 O
3 S# h. l$ B0 ?5 b# d* F/ W9 y
解决办法8 K( d* O) z( e7 Z: S
1、卸载nodejs重新安装一遍
8 M) q2 f0 E9 q2 X& v' s9 |; S- x& F" n) Z, @" u
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org& V( ?4 S% n6 G

: }- T: y9 O% I# g3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
% y- H  Z7 F. L' [————————————————- J$ b' f4 l$ i4 N; n4 m$ F# W, s  t
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。/ w% [# c# Y- H8 z; ?. [4 k
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

520

回帖

3460

积分

管理员

积分
3460
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
" ~. @& s; E- h3 C+ `; b( E& E* c3 `# H' k' T$ @- t9 L( h+ X4 K. G9 t
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
0 g5 m9 R% y2 q2 N8 ]& S0 i" l5 }% t/ a8 E
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!" D6 I8 r; v4 F# S) Y7 \
————————————————( G) j1 y# i  y( \9 _2 }  f4 W; D& }
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
" w: |0 G/ r, V7 ]" W! p# w* s原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-1 11:47 , Processed in 0.016315 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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