找回密码
 立即注册
查看: 1131|回复: 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 | 显示全部楼层 |阅读模式
报错信息:. O3 ?' C3 Y) y* I6 h% s/ P
```bash
9 p9 L" y. u6 }6 e% e) Zgyp ERR! find VS
/ R2 J+ \" h1 A' h  b8 |/ U7 m0 ]' Hgyp ERR! find VS msvs_version not set from command line or npm config
: Y  F; ^# q2 \  w" }* k* ngyp ERR! find VS running in VS Command Prompt, installation path is:
3 X8 `5 _5 T0 h. m) W5 pgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
  z% q. X* @3 s5 _. t7 ]- A5 ]gyp ERR! find VS - will only use this version
, T" ]- T. v! E& H, egyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
2 A. a2 C  \4 B5 ]. o7 ugyp ERR! find VS looking for Visual Studio 2015$ {# L: e6 x6 q
gyp ERR! find VS - not found
" u% T- F9 c. F! g# x* Ogyp ERR! find VS looking for Visual Studio 2013% H! c8 ?/ y: d! e8 X4 o2 _' k+ u
gyp ERR! find VS - not found  N6 i2 \+ R% }; O0 I% ?7 w, }5 L- s
gyp ERR! find VS7 \) K* C  s! k0 x. V
gyp ERR! find VS **************************************************************  m' C& h( W: |9 |. b% u
gyp ERR! find VS You need to install the latest version of Visual Studio9 A; m" R9 K6 K6 D' Y1 j( L7 ^
gyp ERR! find VS including the "Desktop development with C++" workload.8 T* g6 l1 H2 ~* Z! r2 f" C; I
gyp ERR! find VS For more information consult the documentation at:2 u: V* F$ c8 y
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows( s# s$ ?8 ^( l" T( {; O* }
gyp ERR! find VS **************************************************************
  i1 \8 X1 y8 `: V' `# b/ Ngyp ERR! find VS7 _  X4 q/ w' ~) \4 K
gyp ERR! configure error
5 f9 }" Q0 h% h  Q6 {: ~gyp ERR! stack Error: Could not find any Visual Studio installation to use
! u3 L( ^- E. ]2 _gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu  u9 ~2 X% y% V& a3 C6 J$ g
dio.js:121:47)
- P) c/ x9 }' \% a% n2 }* Igyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:167 [9 J' |2 ]; s
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
0 _! `5 D1 Y2 k, \( Tgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7# m8 N$ X2 a6 \. d$ U
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:167 _2 J4 S3 R4 s. F7 r
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)1 q( L( b4 A5 u. }$ d
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)  e$ `& g+ @. [! V3 Q& X- ]8 Q7 s  J
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
; `8 {+ K( t$ G- {: kgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5); v4 T. ]& E$ S/ g& e" y& n- w
gyp ERR! System Windows_NT 10.0.15063
" \. t* c( [+ T0 D# C0 m2 F" k/ Y1 Z
8 Y  U6 L% D. H
解决办法
0 j2 Q! ~4 w4 {6 ^) D" t+ |" h. u1、卸载nodejs重新安装一遍
2 J6 ~& U/ |: A: [" A$ T' D. z" U" Q$ o
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org, a4 x* W& Y! H- _# Z8 ]

! ~; R8 z$ [& W) k- [3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools
5 [% m6 z  e5 {) c————————————————1 C+ |5 M- T+ ^) C. r2 O: O. W' ]
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。. Y- D0 r: [1 `' j9 O& |: u
原文链接: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
# m& ]+ t1 U) J8 l) `* n5 E6 N. a  c, d: G( ~6 Q0 U3 @
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。* Q0 d6 c* }1 H0 Y5 `
3 z- @2 q2 E# A6 C, M/ j- |- b
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!* f. m: y/ M4 [/ m" E
————————————————1 ?$ P, R+ e. Z# F3 C; D( B* Q
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。. i% e/ r: y3 @% g
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-22 10:53 , Processed in 0.014752 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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