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

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

[复制链接]

331

主题

511

回帖

3355

积分

管理员

积分
3355
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
6 I# A! x- N, b! s' y# w+ k" O
```bash
+ Y9 y. v% V  r' R3 x, Hgyp ERR! find VS
& Y( O+ k) I% F8 R8 I8 {+ Z$ Mgyp ERR! find VS msvs_version not set from command line or npm config
6 a+ {, z" b5 x5 f( Y( o, E/ {: ggyp ERR! find VS running in VS Command Prompt, installation path is:  w" K4 }& {  M5 o; T  w
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
$ p/ F+ D/ g* }' S7 i0 v' N$ Mgyp ERR! find VS - will only use this version% I0 P# y, ~0 l  m+ D
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
+ \- e9 D8 V, N) A& n0 D, qgyp ERR! find VS looking for Visual Studio 2015
2 u. G- M8 c. e( T: e% ogyp ERR! find VS - not found( }+ h- W8 I  W& Q! I
gyp ERR! find VS looking for Visual Studio 2013
) A4 B0 N( C8 ?  e8 N* Bgyp ERR! find VS - not found
. C* l, ], J3 z& m# x+ Z4 wgyp ERR! find VS
1 F: i2 }' K: J& u2 Y- _  M* Jgyp ERR! find VS **************************************************************
1 U. @3 }3 }5 m! W( s* F4 pgyp ERR! find VS You need to install the latest version of Visual Studio8 c1 l3 r' {! i* q
gyp ERR! find VS including the "Desktop development with C++" workload./ [! i! a8 x7 }# @
gyp ERR! find VS For more information consult the documentation at:+ s+ Q. b; D: b" O
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
4 g  g- [+ X3 @+ igyp ERR! find VS **************************************************************8 _, R0 X: ?5 M  k! x6 e  p. [
gyp ERR! find VS8 e* W1 }1 q; N' w- Q
gyp ERR! configure error
; w/ e' ^% `/ Q- ogyp ERR! stack Error: Could not find any Visual Studio installation to use
0 h' @$ d0 j" g5 ]gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
, D" T1 l, I( `( d6 _  y9 L- {$ adio.js:121:47)6 h: Q) k# Y4 R4 X& I
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16- d  F; |* y% R* S- }' k
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:165 f3 U& n3 q! ^& u( o+ D
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7- `% A' g6 S( j
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16. A5 N9 h6 ~( I' F) m+ H% e) K
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
  G/ ~- m! [3 \# }. Z: R2 }( Kgyp ERR! stack     at ChildProcess.emit (events.js:315:20)6 |9 s4 W2 K+ ~% ^; R, f, Z
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
4 v+ W1 t; i$ g7 x* z6 X1 jgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
& D; B3 j6 K0 U) agyp ERR! System Windows_NT 10.0.15063
2 _- L9 g: M9 ?8 s8 Y6 {
0 b5 Q; i. o0 d+ D0 k* Q) `
解决办法
. C* o9 z7 B1 ]% A  Q/ d. s2 w1、卸载nodejs重新安装一遍
: z6 j& a  W. f' l6 y' h! Q/ v0 r0 W' ?, _  r9 H
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
4 p7 o7 g* U/ P* m1 h4 H4 t9 X# C, t9 x& E7 w
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools, y( L4 c1 R% f
————————————————
  K! k3 c( A! o版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。2 Z! K. l/ d3 ?2 B
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

331

主题

511

回帖

3355

积分

管理员

积分
3355
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7) e. p2 E$ ^- r5 x% _9 r, Q
7 G4 X. W/ v8 D3 g
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。) H# e/ y2 [; }, n) a0 S8 z9 ?

4 p5 C+ Q+ a. ^: X) G5 J然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
/ L1 N1 i# `8 `, J' W————————————————
" e1 y& E, ^% N7 r# c- j版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
# b! x7 w$ C0 |- c原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-21 16:14 , Processed in 0.073856 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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