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

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

[复制链接]

338

主题

520

回帖

3462

积分

管理员

积分
3462
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:( ]1 J6 J& r. Q
```bash
; ]1 U8 E0 l0 ?+ Q5 I, sgyp ERR! find VS
3 V: O- T3 n; X( [# y( N, B; Mgyp ERR! find VS msvs_version not set from command line or npm config
8 R0 J" J7 Q& d6 Z1 s! |; Igyp ERR! find VS running in VS Command Prompt, installation path is:0 S2 L8 |# o5 k3 j
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
& a  M7 _! {8 p0 _+ f- o7 Igyp ERR! find VS - will only use this version
2 W) r8 n4 Q4 l4 Egyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer: v/ `- H6 E. ~
gyp ERR! find VS looking for Visual Studio 2015
& R& w$ X( }% t4 R6 }3 ]4 @gyp ERR! find VS - not found! t, U9 a9 z0 ]' [0 y) o2 q. M
gyp ERR! find VS looking for Visual Studio 20131 Z5 z" ?' ?7 Z
gyp ERR! find VS - not found, L+ M( r1 B# ~5 n0 d
gyp ERR! find VS
9 {# ?* P+ T) R! K" d! f, \# h1 H8 @gyp ERR! find VS **************************************************************$ n/ O  s! i+ b! G& S9 t
gyp ERR! find VS You need to install the latest version of Visual Studio' g3 ?6 c2 J! q& V6 \! m; o* P
gyp ERR! find VS including the "Desktop development with C++" workload.: E+ C) o, k6 }* K4 z
gyp ERR! find VS For more information consult the documentation at:
7 E1 q; S6 A/ p1 |gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
; X8 E; e0 Y2 U$ M9 l4 T; c5 Sgyp ERR! find VS **************************************************************
/ y: V: \5 X3 G/ l0 Q' g  U2 Ygyp ERR! find VS
, d  h' I4 n( W* ogyp ERR! configure error
& s+ E9 F: `$ Ggyp ERR! stack Error: Could not find any Visual Studio installation to use9 I2 X2 o# \! Z. O5 Z7 W( x/ Z
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu! l$ _' ~( b! V/ L) m
dio.js:121:47)
# s/ S5 S% J$ F4 ^6 Kgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
$ U# I! ^7 z0 _; ~: Q- K: I: s! }gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16; u! z1 R$ X/ [) s$ [* o
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:76 g( _3 t& n; H- O
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:163 }7 V4 w, P  v1 `+ v) Y
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)3 t, V) W$ m, B( l8 A# F8 v3 d
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
8 j3 J$ i/ |5 ^8 r8 G" c( E: }7 `) |gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)% Z; J" y% W! k2 U8 ]) ^
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
  a% w( b. W& R( agyp ERR! System Windows_NT 10.0.15063

/ f. D# k2 _/ p8 a# g0 i2 T, ?# g: U5 N6 Y
解决办法% Z6 u. t- q& `7 ^: z9 G3 X
1、卸载nodejs重新安装一遍
7 o; c5 a$ n* `6 X
# ?3 z+ G& J) k7 }) F- I2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
4 ]/ S" Q  x4 i+ E* i: p, h
( ]4 s) s" g: M' X3 x3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
* a4 v9 I2 S* ]8 y————————————————
7 I% x& g  C! _版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
* E3 ]4 Z; F4 A1 S原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

520

回帖

3462

积分

管理员

积分
3462
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
- F+ s. R$ O1 B) R% N: Y; P- W
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。' N5 B, M0 H9 G  h9 w* A& m

, \& p/ N; I$ \然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!1 y6 C6 Z; K4 i  n2 M( z
————————————————5 F4 Y- s) B7 g2 v
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。* a  v; Z- V0 `. k
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-3 12:50 , Processed in 0.018303 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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