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

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

[复制链接]

347

主题

565

回帖

3689

积分

管理员

积分
3689
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:% d3 E' c, o7 M& e6 N4 R0 d% F2 A
```bash7 `) ]7 Y3 G2 I' t  n
gyp ERR! find VS; v% N7 |) q  F4 w& ?7 y! n. @
gyp ERR! find VS msvs_version not set from command line or npm config% G# q% r& k5 V7 w
gyp ERR! find VS running in VS Command Prompt, installation path is:/ n* w0 j+ z: [4 ^' X- [) w
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
  M; }2 l. @& P" h+ q( [3 Mgyp ERR! find VS - will only use this version7 v0 _! H3 o2 c$ C
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
0 @: f/ |. ^4 q* b. z2 tgyp ERR! find VS looking for Visual Studio 2015
7 t8 q( `5 o, Xgyp ERR! find VS - not found
2 k( E# d+ c7 Y) y2 Jgyp ERR! find VS looking for Visual Studio 20137 }: U+ W$ D. C2 i+ q
gyp ERR! find VS - not found" V9 [( f! x' f' b' U
gyp ERR! find VS
9 u2 d( H0 A" l, H0 d5 b1 I  Wgyp ERR! find VS **************************************************************9 ^* \- V% f2 r$ E5 e- }9 P1 s
gyp ERR! find VS You need to install the latest version of Visual Studio! U: y" t- p) N. n: Y
gyp ERR! find VS including the "Desktop development with C++" workload.
1 y- L$ [( a: W3 ?gyp ERR! find VS For more information consult the documentation at:
8 A3 H+ p: m- b) K! ggyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
: u4 a& `* h% Q3 T6 agyp ERR! find VS **************************************************************2 F- o$ |5 A) b. m
gyp ERR! find VS8 w2 d7 D4 |0 u
gyp ERR! configure error' s" T) _- `6 Y+ h4 ~1 H( P
gyp ERR! stack Error: Could not find any Visual Studio installation to use
. c0 V" e% y" x  Rgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
7 m4 d# n* ~3 v2 E9 e) W9 _7 c) mdio.js:121:47)" [, _6 ]0 k) \5 i3 q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
% B7 Q( e0 S3 v' I$ `/ Egyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
; B) t+ ~- i2 o% lgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
' P8 g# R& s8 L6 L9 c: lgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:163 e1 O3 p+ M5 ]# S: D1 z- R
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
' @+ J- q+ l% ^% a) @2 @$ @1 {* Tgyp ERR! stack     at ChildProcess.emit (events.js:315:20)" `  L8 V1 d+ `4 z6 p& B
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
8 [+ D) }/ U# d; ]gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5); s6 I5 e% a& S8 w% `! e+ _
gyp ERR! System Windows_NT 10.0.15063
4 a! m& W% {# }4 x* ~
; A5 `/ z! `; @' X; m: G
解决办法
4 n7 z( x( X0 s1、卸载nodejs重新安装一遍
; P- R5 w! d$ f) Y7 e" @
4 Y1 ]4 P" R% O6 w0 e2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
6 O5 i7 Z5 t0 X1 X( Y) _# c6 b" r  z1 K  m- I/ h
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools/ E5 e4 V5 R0 K" _! N/ d4 r0 c$ S
————————————————% o, A$ \  b  l2 |5 Y; b
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。0 r6 b7 o- H% ^( R
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

565

回帖

3689

积分

管理员

积分
3689
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
, O, d/ T6 E* E" h! m" w
  R) R" J5 p9 d+ L/ A由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
% d3 m2 }" W0 P* t
& u6 P' ~. m9 [  h2 [% d然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!4 Z: l+ H/ o1 o! u  G  ^3 _
————————————————3 A! N3 u1 S+ w4 F; X2 F
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。" f( ?) p  o! b/ }& m
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-19 05:01 , Processed in 0.012107 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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