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

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

[复制链接]

340

主题

522

回帖

3502

积分

管理员

积分
3502
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
) i% ^# ]1 W- b$ m
```bash
4 i; s; P) {2 h0 E7 Lgyp ERR! find VS5 a* a" q% r  k" E: _
gyp ERR! find VS msvs_version not set from command line or npm config
% N0 d# C* i7 C7 @gyp ERR! find VS running in VS Command Prompt, installation path is:- L# h- u% X" W6 ]- q1 u
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017". L  i' B( C( Z9 i0 ]
gyp ERR! find VS - will only use this version. f; v) D% P. U: S
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer. `7 t. j  c* u% `4 ~
gyp ERR! find VS looking for Visual Studio 2015
# R' t$ ?/ o: o4 T" ]7 hgyp ERR! find VS - not found
: x( O3 c+ z6 h7 y/ Ggyp ERR! find VS looking for Visual Studio 2013
% M- M) ^5 }' f3 A) wgyp ERR! find VS - not found: B& |4 T9 F! W$ E4 Y! e
gyp ERR! find VS
- \. h0 U5 Z: T/ Ygyp ERR! find VS **************************************************************
7 }  H$ Z* a3 V7 j; Y% |) }8 j( Egyp ERR! find VS You need to install the latest version of Visual Studio2 r; n* x; \! n( w7 C2 X/ A
gyp ERR! find VS including the "Desktop development with C++" workload.
5 D! e' V3 u7 t( jgyp ERR! find VS For more information consult the documentation at:0 g$ F5 a1 n' c2 A+ o
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
! s9 G; y2 D# v& |4 T' g7 agyp ERR! find VS **************************************************************
8 |2 [3 Q. {/ V6 K# a+ Rgyp ERR! find VS
3 q; I( q, L, t; N8 K2 Hgyp ERR! configure error0 [" E- y0 E" u' @
gyp ERR! stack Error: Could not find any Visual Studio installation to use
- K4 X6 Z7 W% n/ J- ygyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu! }+ `0 @3 {$ ^  X% J$ w& ?" B5 ]
dio.js:121:47)- `: m$ k% b- m
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:163 k# ]4 H5 H3 X6 E" N% u
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:166 o- y+ q2 C$ C6 X- ]) c
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
( B% \: t; l+ h, t4 R5 Pgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
8 K- @. d# y% D0 s! t* V/ V$ j  _  Wgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)1 d1 P2 ]; b8 @3 i% f% {4 g
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
* v0 N3 d; I) p$ ~3 igyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)5 v4 N0 t- V0 p# I
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)% w( t& R) ~$ R% [; Q' P1 J
gyp ERR! System Windows_NT 10.0.15063
$ ^0 u' {: Z, \0 k. a, H

' c- x( y7 Z  P解决办法
9 X' y$ C9 \4 C2 y( \0 @+ G1、卸载nodejs重新安装一遍
/ e' U6 U, ?! e* }9 i! |8 j) I2 Y9 J  p$ @9 }, M7 x( N/ v
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org* W1 R# a6 j- u; s

( N! b1 H7 G: x4 ^/ c1 ?* T3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools. n/ L. M: E* p, r# G
————————————————
" Q* B) j3 V3 E. ~& g版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
9 X, H1 l) E8 l3 w原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

522

回帖

3502

积分

管理员

积分
3502
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
6 v8 v- G$ X7 B- e1 K4 E  ~3 v& X7 M5 o2 q- A8 R5 g/ T0 }- I$ |
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。1 N" J" \9 b1 a$ K
/ p5 b+ }: F8 D3 {
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!5 V# E" H, Y" R- n) V
————————————————$ {6 a% i0 [4 i- C
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
# N/ \- i( h* u/ w( E  X* V8 |原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-14 12:55 , Processed in 0.015234 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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