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

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

[复制链接]

338

主题

520

回帖

3454

积分

管理员

积分
3454
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
0 ?4 ?, \5 J7 A  j9 b3 p
```bash, g8 C/ G, j4 z; j
gyp ERR! find VS
. E! m) W" `* C0 I( h: Y. i; m5 Mgyp ERR! find VS msvs_version not set from command line or npm config+ u' b  S! s( K5 t2 `' r
gyp ERR! find VS running in VS Command Prompt, installation path is:5 S3 k1 Q' D& o. U0 F$ h) k! |; q* y
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"' d! I' o4 u7 z3 q: v; A" K
gyp ERR! find VS - will only use this version
# j+ g3 f5 U8 {gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
/ y# R& ~: y& s' mgyp ERR! find VS looking for Visual Studio 2015' A4 w/ X' C5 O5 x- c! v& P$ ?/ e5 ^
gyp ERR! find VS - not found- w' t% B6 Y6 Q! r
gyp ERR! find VS looking for Visual Studio 2013
  a: n/ ~. N. }9 _- rgyp ERR! find VS - not found- J( X$ k& S* ^
gyp ERR! find VS
. |5 g2 x1 i2 Kgyp ERR! find VS **************************************************************
5 `2 P. \2 @, I. |3 B& U# J8 f% i1 xgyp ERR! find VS You need to install the latest version of Visual Studio
" Y/ }: y2 w" r+ e4 A: Y) Z$ J. Agyp ERR! find VS including the "Desktop development with C++" workload.( B" x$ o+ @+ T: p3 r; b
gyp ERR! find VS For more information consult the documentation at:
9 Y, F# `+ X' F" h( L/ j. ~gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
) v7 W7 ?( V, f- C! g5 W/ I5 X1 {! |gyp ERR! find VS **************************************************************7 W1 G4 o3 Q( S1 [  ~2 ?
gyp ERR! find VS0 |$ [2 k, O; U) `) j, ?
gyp ERR! configure error  h$ A9 a% F/ |; A' Q
gyp ERR! stack Error: Could not find any Visual Studio installation to use
3 a0 X* ~0 h  ~1 N' M# Sgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu3 S) \" T$ Q% @- X: u
dio.js:121:47)$ j* ]' w2 a# X6 A& p
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16# U* t5 M6 h7 Z* k+ i
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
. o. [' e! r* w5 ?2 ?8 i9 {gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:75 o5 D: I+ H% N6 T
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
5 [& v2 W1 ~; E. B1 ]5 {4 E% D2 igyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
% {8 C4 x, g, X4 k: b- ugyp ERR! stack     at ChildProcess.emit (events.js:315:20)$ k  c3 b+ v( \9 G9 H: C3 `8 `' o
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)/ `7 o8 y4 b- ]! n7 o
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)& P3 Y# g9 w; a' E9 f" ^( D
gyp ERR! System Windows_NT 10.0.15063
* c& t9 A, U: ~" N+ g8 |
) ^& I- n" k! v: t% x! G
解决办法# z" w2 B4 y8 M' j8 t1 K3 `) r
1、卸载nodejs重新安装一遍
8 [  i0 I" R& I" y
1 t' ^3 b* W0 Q9 L9 C2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
, V" e1 \5 j; U
, K- e& @' c: t4 U/ m' _3 I# y$ L3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools* m9 s6 j  q: ], T3 ~( _
————————————————
1 B  A/ M7 m9 k版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
/ A  n8 b' l+ }6 U- F4 _: |原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

338

主题

520

回帖

3454

积分

管理员

积分
3454
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7& Q: b  O% C+ O/ e( p' h) P
- [+ z# I3 W9 D
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
5 O$ ~# e$ A7 d# z: [
: j2 K, K" e/ R  ^0 o然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!, I. q) x& t6 ~4 I% x  W7 b$ S- [/ ^
————————————————7 e+ ?% v" C) C* h' L) o/ I- c4 y
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
1 ^5 `0 ^0 ?8 e/ }0 G/ t原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-23 08:29 , Processed in 0.015049 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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