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

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

[复制链接]

340

主题

530

回帖

3542

积分

管理员

积分
3542
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:. Q. E5 O) M# g( ^, Q
```bash
6 h7 x3 d6 ~$ T0 q6 P+ Tgyp ERR! find VS
& B& ^6 L- S1 a! |gyp ERR! find VS msvs_version not set from command line or npm config
  w4 f7 O, d2 z/ l! tgyp ERR! find VS running in VS Command Prompt, installation path is:/ n/ |) G: @8 ~2 n1 }, ^
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
. X* e9 R% q' |) R/ W& b, R& pgyp ERR! find VS - will only use this version
1 o( T- }2 P  L5 k) `7 H2 jgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer1 {9 f! n; S3 P- g3 t$ X; P* b+ [) h
gyp ERR! find VS looking for Visual Studio 2015
$ {. T/ J# M) O5 i; Egyp ERR! find VS - not found
. z' r) g* I/ R  j) e' v( Ngyp ERR! find VS looking for Visual Studio 2013
$ f% W2 Q3 d9 x  ~- S( ~gyp ERR! find VS - not found
) U/ x0 E: t9 ]% cgyp ERR! find VS$ L5 G/ y& t% m' y) v8 r& w
gyp ERR! find VS **************************************************************  a. y& T7 L6 Z7 {  _: {
gyp ERR! find VS You need to install the latest version of Visual Studio( B: Z; w6 G6 m
gyp ERR! find VS including the "Desktop development with C++" workload.4 w6 W# ~. P2 x0 S/ X- |
gyp ERR! find VS For more information consult the documentation at:
; G+ u  l  R( C/ ]( o! Ygyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows& `' w! F0 z5 N# x5 H
gyp ERR! find VS **************************************************************& I* `# ?2 v+ Y% l% h
gyp ERR! find VS
2 |# z4 N+ M9 M: e) R; Ngyp ERR! configure error+ m: I' o0 h: r& P
gyp ERR! stack Error: Could not find any Visual Studio installation to use8 h; s$ y, u9 _+ @$ l- }
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
1 K8 m2 p/ G6 ?5 |& J4 W* Cdio.js:121:47), x9 F1 i* _0 M# D+ u
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16+ U' c6 T1 t+ [( b+ N6 u* F
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:162 v. V! ~: {: _
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
8 ?6 A8 n, Q( k& R. v' b0 a/ u/ lgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
  ]3 f4 y! A7 \' Y6 bgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)0 A6 g$ N" Z5 L
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
* N: x7 d$ S7 k- C* Cgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
+ a9 G0 h( {. c& Z; p) t6 {gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)) n7 f0 Y) y# ]' _5 N2 [9 n6 L/ E
gyp ERR! System Windows_NT 10.0.15063
3 L% g, G) k: S6 C# N

  K& s2 u2 r: R) J5 n  I解决办法
0 }. _/ h) U( O' X/ J1、卸载nodejs重新安装一遍
9 d5 R  k! D1 C* s9 Y: W9 ~  y1 N! [3 }) n
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
' N8 ^7 P3 |  o
6 c$ H) H$ [& f3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
8 I( O7 _4 L& p- ~/ n————————————————$ u% Z+ Q" N2 z' X7 q  ^0 ]
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。1 t# z' J1 C; Z9 o( q
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

530

回帖

3542

积分

管理员

积分
3542
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
$ d/ j0 v3 V* |) K% s5 o& |" b9 M0 a" A4 g" S
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。( ~1 B% y7 N2 R: I/ X0 M
- x: E& d5 S1 Z) }, }0 l$ E
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!( ~7 G/ O" ]6 S# _( h- J3 u
————————————————' _7 {- F  t; D
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。5 V  l7 V% u( x& F- `' K3 P& o% b: T
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-23 00:45 , Processed in 0.014423 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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