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

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

[复制链接]

328

主题

499

回帖

3260

积分

管理员

积分
3260
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:  d% M) C9 G; y5 ]
```bash. U. u6 O4 l9 d4 C, g4 O7 J
gyp ERR! find VS/ k; u. d; V8 }" y
gyp ERR! find VS msvs_version not set from command line or npm config5 a3 W. m! v3 x+ [) x
gyp ERR! find VS running in VS Command Prompt, installation path is:* S/ j$ X/ ~- @1 `  n& q
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
4 j5 [. G; ]$ a) `6 F6 V0 Kgyp ERR! find VS - will only use this version
+ F. p( T7 p, Z, D2 vgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer' u* ?! k: T9 c
gyp ERR! find VS looking for Visual Studio 2015
, m' h$ [' c* w; P( {gyp ERR! find VS - not found
& v) r5 Z3 x. vgyp ERR! find VS looking for Visual Studio 20137 n, P( I0 f0 k' c) o& ^
gyp ERR! find VS - not found
1 e) |0 I4 X3 G; ?0 [1 T" W0 Cgyp ERR! find VS; `; K6 z: t1 J7 ?2 E
gyp ERR! find VS **************************************************************  C0 O( ^4 m* {/ _7 U
gyp ERR! find VS You need to install the latest version of Visual Studio
2 x& M$ O! ]" ]+ e6 t; R% Dgyp ERR! find VS including the "Desktop development with C++" workload.. _6 u7 J  J/ N/ x! R* T& N) f8 A4 i
gyp ERR! find VS For more information consult the documentation at:
- W* _7 R$ c" ?  mgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows0 ~% O, m9 ~# A! N: U5 Z( D
gyp ERR! find VS **************************************************************
  Y8 i6 `/ a) agyp ERR! find VS
$ p  `$ x4 o# Ygyp ERR! configure error  ]$ f' }, v2 e% d
gyp ERR! stack Error: Could not find any Visual Studio installation to use
8 M& d4 Y1 _* rgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
+ a& W! u' v8 ~0 R. n, C* y! a0 Odio.js:121:47)" F7 M/ ?! g: `# l9 ?8 d; e) T
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
$ ]3 o, U+ z  L* }  }; Fgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
% ^& @( e. H- ]5 P( g# ~gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7- y+ x  ?$ n4 n) o
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16! N: m5 n. f& P5 X
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5). [9 D9 }9 V1 ]/ x. r
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)1 w/ h' U- z; z9 B
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
: ]4 K( y4 b5 Ngyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)& y0 `9 S5 t  [$ h6 h. D
gyp ERR! System Windows_NT 10.0.15063

4 b5 g$ [. l! f2 [: J! {2 Y) S. l8 K0 _1 q) r' H
解决办法
7 X6 I3 a' R% M- D% E' j) @1、卸载nodejs重新安装一遍
6 i" u: O' i8 ]$ [: [
2 M& m$ o) o. @9 \- i2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org/ Y! A; B- [8 u9 _/ L+ A

3 I( W/ ?) \! u3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools+ x" ^. z1 g" x* r
————————————————
0 v9 |- L; q; ]" @  @" d, C版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
; e/ l& D' w6 l原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

328

主题

499

回帖

3260

积分

管理员

积分
3260
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7- ~1 w6 ~" }6 d4 o. B4 k" E2 G
& y" U' e- J9 V' i$ S  V
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
4 r/ w, \+ x& S5 _7 y+ v: S  s/ V4 z  p) e
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
3 L5 Z* F0 L2 h/ Y7 b3 B8 G————————————————. X/ B( a" ?' X& M
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。' [# `% V  x( E! ~9 q
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-11 02:25 , Processed in 0.075602 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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