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

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

[复制链接]

340

主题

529

回帖

3528

积分

管理员

积分
3528
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:# t; G) R, S5 X5 y9 Z  `# a& k& v
```bash$ E4 _5 N/ T$ t7 Z% ~% a; z
gyp ERR! find VS9 y& z  E+ E: }& X5 {/ t
gyp ERR! find VS msvs_version not set from command line or npm config+ ^2 _+ L- j7 i5 A# w. `- H8 r
gyp ERR! find VS running in VS Command Prompt, installation path is:
0 j* X- |7 K5 I2 o* D* Z) f1 Y7 kgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017") C+ {! \( r+ t  S" R
gyp ERR! find VS - will only use this version4 x. Y8 K* [0 ]5 i5 W' z: h: D
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer! s/ B! y' {$ _$ q
gyp ERR! find VS looking for Visual Studio 2015
& M( ~' P+ \  i+ d7 Dgyp ERR! find VS - not found' c' B5 C" f3 l& i( b8 V3 l- |
gyp ERR! find VS looking for Visual Studio 2013
+ F; o; D7 G' ]gyp ERR! find VS - not found, r% C# L, H: x9 `4 D/ F2 x3 c
gyp ERR! find VS
( {! }7 ~! d1 Zgyp ERR! find VS **************************************************************9 U  {9 `1 w9 E: l, J4 p
gyp ERR! find VS You need to install the latest version of Visual Studio3 x1 I" c( d' m' P% M! p
gyp ERR! find VS including the "Desktop development with C++" workload." m9 G+ P1 u  o3 r3 o. a1 m: N
gyp ERR! find VS For more information consult the documentation at:* m3 Z2 s1 ]! h
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows4 j; l$ U  W0 m" x+ L* J6 L
gyp ERR! find VS **************************************************************7 t; N0 T2 V( |) u& |3 c0 O% C
gyp ERR! find VS5 f. T2 F; C( a1 ?8 z
gyp ERR! configure error
8 N! x* J4 I5 ~7 pgyp ERR! stack Error: Could not find any Visual Studio installation to use, M6 r5 W5 s4 A( d, U- e; S
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
- D* h/ g! D6 f1 c, y( F5 Ndio.js:121:47): V- Y8 k: `5 |" b  w$ B7 E& V' w
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
  d8 m; j5 K* I+ q5 W3 Ugyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16& Z) |7 d- |% Z# |) u
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
# m* a/ @, ~9 @; @/ ~gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:164 U, {: Y7 u4 h3 `
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
' C6 a# y5 b/ B; `. [/ s6 Vgyp ERR! stack     at ChildProcess.emit (events.js:315:20)& f8 Z  w: \* o' |+ Y6 S2 I, h
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
0 q2 Y% Q% H5 X4 D( E( k) lgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5). S+ G2 l4 o7 p0 H+ j! T
gyp ERR! System Windows_NT 10.0.15063

; C  E& f  C) P( g7 F/ v' @
$ b, y% [" C# b0 \& O( W( a5 K% c解决办法
3 D* v9 s+ m0 V% U' l* j1、卸载nodejs重新安装一遍
. F9 }- g3 V1 x# N7 u* K, Q, N+ ^7 ~. r, x( H
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org. h6 E+ V) z* T( e; b- s8 I

# K% F" b  v" q7 a3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
, c0 I- @$ c7 B" Y' d+ |————————————————
% G$ K8 L( ?+ y5 e9 d; S$ L版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
' ?1 i( w' ]3 P原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

529

回帖

3528

积分

管理员

积分
3528
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
. }! f& [, H5 {! U/ t7 @, p" m, t7 l
1 z0 c% a/ |+ H8 g$ {/ u由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
2 {) G: U% a# c$ @8 {- A3 R4 q2 ]/ i& _8 p' |1 T; {0 }
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!9 F, G4 w, r3 Z, }* M, ^
————————————————
3 t+ m0 k) R: z2 n. e) {: t版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。' ]3 N4 L5 U; s5 S& t' b
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-18 11:49 , Processed in 0.014555 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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