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

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

[复制链接]

315

主题

479

回帖

3001

积分

管理员

积分
3001
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:! A9 Z  y' i# r' M
```bash+ F  e+ ^. o. ~8 J9 y7 z6 }
gyp ERR! find VS5 M( S# C, T& {/ Z+ l, X$ k% k
gyp ERR! find VS msvs_version not set from command line or npm config5 @% u% C3 f4 Q$ T* @
gyp ERR! find VS running in VS Command Prompt, installation path is:
. e3 j/ G7 h" c6 K( U% Y4 C0 N/ Zgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
4 j# o. n9 j' _$ {gyp ERR! find VS - will only use this version
. h' e+ E8 y% R' Ggyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer+ v0 @4 b3 ^3 Q5 A, z: v
gyp ERR! find VS looking for Visual Studio 20159 h8 }4 U" C6 I3 k: G
gyp ERR! find VS - not found
5 i# L# E* L1 {" zgyp ERR! find VS looking for Visual Studio 2013; T: e1 {6 A2 s% i3 J
gyp ERR! find VS - not found
) \7 S* c# [: r' S( K# {gyp ERR! find VS
: D' }! c: X; Rgyp ERR! find VS **************************************************************8 a( T. [' B: t, s* b! W
gyp ERR! find VS You need to install the latest version of Visual Studio1 B& b/ n1 U" w# t3 j$ i. r
gyp ERR! find VS including the "Desktop development with C++" workload.- e  _& w8 {4 H7 R: M' j3 O9 H
gyp ERR! find VS For more information consult the documentation at:
/ ~4 _  n- F, y& ygyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
' b- n' s; B* l+ m* I3 l, ]gyp ERR! find VS **************************************************************
) L. k! v& i! W/ egyp ERR! find VS
/ l! x5 K) H9 ]8 Kgyp ERR! configure error1 V. J+ E  S& Q6 @1 D
gyp ERR! stack Error: Could not find any Visual Studio installation to use+ J$ h3 \" f9 D, D
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu9 ]6 S0 A: Z( h9 U5 C
dio.js:121:47)6 n$ o: c) h. W, E+ [6 Y* X+ I
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
1 W4 K# X; S# c- Z9 `( @5 w* J7 Mgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16. f1 \5 |( ~# l# Q
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
$ v1 s4 X: f8 Z( b8 @. t) Kgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16, Z3 _" X8 R1 ]; m1 f
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
# X' n- W) o4 O5 Wgyp ERR! stack     at ChildProcess.emit (events.js:315:20)
5 l4 o& H; |" A2 Ygyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
; f* M- f' s2 ^4 j4 @( ^6 }( ?1 ~gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)4 ]0 W; Q2 P2 r* x# p3 b
gyp ERR! System Windows_NT 10.0.15063
' E4 Y: r. m5 l  Y2 E' m
/ @& g; K/ I, E; A" \& v3 L
解决办法' Y2 @7 x; S) c2 g
1、卸载nodejs重新安装一遍
! y( _2 ^: N! d- k; f8 d( z
* }( y8 h" q  P' w  {2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org) u$ Y7 f& ?( K* d

- q0 ?. G8 V- y* {3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools/ W! G# \7 C7 d8 h  _& g+ H/ e
————————————————
- g7 {# f7 d  o& W* K6 x版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。. g6 P9 {: ?/ m
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

315

主题

479

回帖

3001

积分

管理员

积分
3001
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7( {0 c4 |1 ~9 j$ i$ l0 N

) S& Q3 }, o1 I: t# p$ U: H. V由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
/ D3 [. V. _: V5 \! ~' f1 T  y/ @
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!) F6 \! [6 ?3 G/ k; I
————————————————
, {6 j, g: U% z2 Y/ S版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
* _" w# o' I, {' q# }3 S1 T原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-25 13:50 , Processed in 0.075543 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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