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

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

[复制链接]

338

主题

521

回帖

3468

积分

管理员

积分
3468
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
# k: t* O. G+ Z  G6 d
```bash
; U5 J3 ~" H6 |- ugyp ERR! find VS
9 O4 H! |7 z) zgyp ERR! find VS msvs_version not set from command line or npm config* _9 f' h* g3 D' p( [
gyp ERR! find VS running in VS Command Prompt, installation path is:3 C0 z7 f6 I. D% c& N
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"2 B; k0 g* K! E) N. U
gyp ERR! find VS - will only use this version8 {' {. U! U/ a8 d" C
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer4 b( T6 a5 F1 O, A4 ~
gyp ERR! find VS looking for Visual Studio 2015- g* W* L( |8 U/ f8 L! g
gyp ERR! find VS - not found1 z1 T5 {6 f) z3 W3 Z) h2 V
gyp ERR! find VS looking for Visual Studio 20136 R0 D2 q0 R1 S5 D
gyp ERR! find VS - not found1 O% g$ @4 D+ u, m6 V
gyp ERR! find VS! q' W% Y8 h0 X/ m# _) Q. m
gyp ERR! find VS **************************************************************5 z' |" \( x  o7 p- k
gyp ERR! find VS You need to install the latest version of Visual Studio2 R% N4 }- z( ?) b, j; t' r
gyp ERR! find VS including the "Desktop development with C++" workload.
! v" N4 v1 V( J( {( Ogyp ERR! find VS For more information consult the documentation at:- l1 a$ P4 r4 P  C' s* S
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows' Q9 G1 a) i9 q1 E: E8 P" s
gyp ERR! find VS **************************************************************
4 u+ a" v2 w3 c. G7 \gyp ERR! find VS2 y! _8 `. k* o: u; P' J" m- ]
gyp ERR! configure error" R+ X+ G8 @( J( X$ a/ U
gyp ERR! stack Error: Could not find any Visual Studio installation to use# _$ v; {$ f, d- E! N
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu9 Y8 [/ @, ^8 J/ B! R
dio.js:121:47), [2 |# z2 h1 d, k6 t
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
/ L5 f" F4 ^, }" e# jgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
% c/ y) j) E; t+ [0 X! Vgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
; u3 o5 ]( q' t& F' r5 o! \8 N3 D9 rgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
5 m6 ?' ?8 L; _, [% Vgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)& h3 p3 u4 w6 w% s8 `; c) D
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)9 N% I7 U( o& y9 {% L
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
* |0 H8 z1 a" W" ggyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
) T* @- \. W' p/ g2 F" R# O& Fgyp ERR! System Windows_NT 10.0.15063

. Z* }* S# Y  A5 N
& F& B$ P' X1 I解决办法
. I7 Y0 w6 E4 M% w1、卸载nodejs重新安装一遍
) ?7 b/ ?8 B( d: m
4 y9 j  c2 v5 {# Q' l% a7 q! l2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
' {( L* A2 B3 z. m$ h" @* Q& J8 y* `' g8 t! S7 s2 I
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
9 K( h, {$ `% \————————————————. V- r. r+ l4 j# ?6 m; [2 M
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。2 f. }( f' u2 Y9 a- v2 L; M
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

521

回帖

3468

积分

管理员

积分
3468
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
* \: N/ j9 K1 y- p+ t4 x) F! j# X# E
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
, Y+ s/ @: g" V6 O* t+ D$ @# A5 l" y% h* ]6 A8 Z
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
6 R1 Q, T* l# y. i* o% A3 A! [————————————————2 I, |! H* v' E" K+ L
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。: _, V4 k: D8 W8 {$ Z
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-4 23:53 , Processed in 0.017123 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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