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

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

[复制链接]

335

主题

520

回帖

3429

积分

管理员

积分
3429
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:2 t6 M/ F8 v& K! Q6 _) g
```bash
3 q: `0 k: l2 O# k8 }; Zgyp ERR! find VS: n. n# |2 `5 [  t4 ~8 k
gyp ERR! find VS msvs_version not set from command line or npm config  y7 C3 w& o, h1 n$ `
gyp ERR! find VS running in VS Command Prompt, installation path is:* t' H; A& f2 A: h
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"; V( q! P6 u: |) ?8 v6 ^
gyp ERR! find VS - will only use this version/ b, j7 `- D( w- U  P- q
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
/ F/ U' E/ S5 zgyp ERR! find VS looking for Visual Studio 2015
$ P! O+ _$ v6 K- r) f, \8 kgyp ERR! find VS - not found
! a3 n( y* Z7 P6 z) X6 B& v4 Xgyp ERR! find VS looking for Visual Studio 20131 R, g! d$ U/ x; X
gyp ERR! find VS - not found7 j$ t7 a, x6 T" X' Y+ P
gyp ERR! find VS
9 N' E3 t, u  E; sgyp ERR! find VS **************************************************************: J9 t- A: Q$ F
gyp ERR! find VS You need to install the latest version of Visual Studio+ a  s, ?+ z, y+ ^. T6 M
gyp ERR! find VS including the "Desktop development with C++" workload.
, B2 a8 X" D/ h6 W* ~, ]5 rgyp ERR! find VS For more information consult the documentation at:
; d0 y) f4 M% h6 W; I7 Kgyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows. q8 }: h0 ]# k, g7 H( s; @
gyp ERR! find VS **************************************************************7 K9 U3 N, p; q+ K
gyp ERR! find VS
+ M6 _+ z6 s! h9 ngyp ERR! configure error+ K, ]- H% d7 e6 |6 m
gyp ERR! stack Error: Could not find any Visual Studio installation to use
1 n' a6 A) y7 f# ^/ H# \1 c! Ggyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu% [: K$ R9 f* j: v4 ?3 d
dio.js:121:47)
2 C1 a: t8 D( f0 U: o2 t* k$ Igyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16) V/ w# F1 ]$ @: |% {: }3 b
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:166 |3 b, h, O% F' u" d2 F
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:79 v: `4 o! M6 ?! G
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
, y6 U0 }) w6 [5 _6 e  j/ |6 u) ?gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
. k1 J9 [  z6 W5 O6 e/ B& \. [7 W! {gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
: z0 W' l" ~# z0 m& E9 cgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)' q5 d* I; O$ x  u
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
) ?7 j9 f3 L' Pgyp ERR! System Windows_NT 10.0.15063
: Y1 T+ C3 i: r2 ~! C- T

+ F- e% N) \1 [5 i2 O/ `, i解决办法
, @6 z) I9 }7 p$ Y1、卸载nodejs重新安装一遍3 O( A9 U/ N) @/ g! r# _' a8 ~

# ^# a( h; n" v8 y2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org& q, E  N/ P( d1 a4 d6 D
+ o' H- F5 N2 K; H  b7 V$ a
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
2 Q% ]+ N6 o  S2 s* S# ?————————————————" j3 X* X8 u0 m  M
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。& ~+ p$ l, A! w" E5 X
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

335

主题

520

回帖

3429

积分

管理员

积分
3429
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
4 v, j7 o4 h+ p' |2 m  B
+ M# l( l  n4 Z& l8 r& D由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
$ i) d! B) Y/ l' I4 {- F/ {6 p" V/ v' @2 q: }8 P3 _
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!) k5 P0 Z" ~0 p7 Z9 L% i9 Z
————————————————! c3 t+ W- |7 p2 X$ d. r/ ?
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。) @9 F3 |4 C& W% c" t/ i
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-14 22:03 , Processed in 0.067999 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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