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

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

[复制链接]

347

主题

563

回帖

3675

积分

管理员

积分
3675
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
# w9 e. R' E7 Q' U* @
```bash
0 C6 W& {# ~4 I+ n8 @1 ^" ygyp ERR! find VS- T* y- J# Y; N/ Q
gyp ERR! find VS msvs_version not set from command line or npm config
7 E- M9 N+ H! F3 Q& c- [gyp ERR! find VS running in VS Command Prompt, installation path is:, P5 m! ?* \3 R5 u  I
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
1 T2 E8 v( G7 L* u! Agyp ERR! find VS - will only use this version
  M5 i1 I: N* D2 h' {gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer( O, Z+ l6 g9 {" X7 N% [+ t
gyp ERR! find VS looking for Visual Studio 2015+ p7 M2 C  G3 Q) V# V. \8 D
gyp ERR! find VS - not found
4 y' h9 i& K6 egyp ERR! find VS looking for Visual Studio 2013# q1 i& z# N' j- p# `7 U) h
gyp ERR! find VS - not found9 H8 U' E% G/ H1 U
gyp ERR! find VS
6 x# Q/ e  U. p+ j% Tgyp ERR! find VS *************************************************************** |. q/ I2 H5 n# F+ p
gyp ERR! find VS You need to install the latest version of Visual Studio+ _' ~$ |9 R6 }  V
gyp ERR! find VS including the "Desktop development with C++" workload.
; I1 k; x/ F& q7 Z3 ngyp ERR! find VS For more information consult the documentation at:9 k5 ?. ?: a' T( H
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows1 L1 c- F' e0 M( X- k1 X. k! d, w4 J
gyp ERR! find VS **************************************************************
' Y9 y* S5 G6 U% ~8 Bgyp ERR! find VS
8 J8 \* J; j6 w: b: mgyp ERR! configure error
  P0 h$ J8 J- D0 lgyp ERR! stack Error: Could not find any Visual Studio installation to use
- g8 L5 Z2 m6 o) S# M3 f8 D; Jgyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
. b& y  J8 Z- e! ~7 |  ^5 C  edio.js:121:47)3 T. z7 I! O+ w
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:167 z$ O& u; q$ Q% e
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:161 Q/ G; K+ n' a# B9 q- r8 d5 e
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
6 k( p7 X: y! U7 R: v$ dgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:168 g/ R  {/ p  u( R& r
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
4 Z% L* C  Y: k6 @gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
& O: l. J4 \8 B6 \, r4 Hgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16), G+ r- Q& M$ l
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
7 {8 }7 h% s$ l. t  G3 vgyp ERR! System Windows_NT 10.0.15063
, _3 B" ]  [7 N. J# ~

2 X5 p% N: i9 `( {: r解决办法
4 J% W( Q5 O; s& N1、卸载nodejs重新安装一遍
, i0 ]; m7 P4 B! A8 v. Z% ~% a
" {$ `! d8 }- Q. R2 T* B2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
9 R0 H& @0 u# l: X
) V% X9 ^0 I7 _; h4 C+ i- _4 p, o: s3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools7 e! S0 q- O; ~" E6 W
————————————————
, I# `8 m/ B- z/ ?) E) z) |8 [版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
5 p% A5 Z- k# G$ c7 N4 K原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

347

主题

563

回帖

3675

积分

管理员

积分
3675
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
5 p/ v$ ~' J8 x. H
! U$ J# P0 Y; G3 J9 W; i由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
" ]: V4 i5 E, H( x: S" U  Z+ h1 t- l' B$ V# }. F, [6 B  p# w
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
5 n6 e; T$ y7 }: i# K————————————————! G; @, C! Y; A- U  r
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
4 V7 g2 S4 y$ R. r- x原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-7 08:49 , Processed in 0.012081 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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