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

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

[复制链接]

340

主题

522

回帖

3494

积分

管理员

积分
3494
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
" E( x9 {, y3 K) P: Z& P
```bash
, X% P: f  d1 R6 c+ P+ u' L! f' Tgyp ERR! find VS
$ j) [) q7 @; l; Q6 Ngyp ERR! find VS msvs_version not set from command line or npm config
- C1 Y5 T0 \7 s- F1 \% j9 [gyp ERR! find VS running in VS Command Prompt, installation path is:
5 c) {7 Y: w( y( @3 }gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"' S; C, W6 z: N! V1 B2 C$ r
gyp ERR! find VS - will only use this version) U- c: ?; q9 h$ S9 q
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer( X  _/ w0 d& ?2 U
gyp ERR! find VS looking for Visual Studio 2015  i, e/ A9 r3 U9 ^5 j
gyp ERR! find VS - not found
7 S& Z! h. K9 ugyp ERR! find VS looking for Visual Studio 20139 [* ~; L/ C9 U
gyp ERR! find VS - not found4 T& M5 p' ?7 p& e/ P( P5 i, j7 D
gyp ERR! find VS
+ \  i: Q6 Y+ f3 b" u6 l2 Pgyp ERR! find VS **************************************************************# b( W2 F  ?+ }2 X* F
gyp ERR! find VS You need to install the latest version of Visual Studio
( o, c. q3 q0 egyp ERR! find VS including the "Desktop development with C++" workload.3 L* @* y5 z* Z5 Y% W' U9 ^- `
gyp ERR! find VS For more information consult the documentation at:) R; Q# K' C+ L, u# c: f8 |
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows7 K  g) C$ Z5 p0 A7 v1 q6 e
gyp ERR! find VS **************************************************************7 ]5 `: S  P/ `" r/ ~
gyp ERR! find VS: q8 E9 v7 [; I- @+ J( }* p) A; e
gyp ERR! configure error) W6 X& y. y4 t9 ~) j; h" B+ X
gyp ERR! stack Error: Could not find any Visual Studio installation to use
6 ?7 b" J8 `: Ngyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu/ K: ~- z! j4 j: v! R
dio.js:121:47)
3 K  q8 \, F3 r/ hgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16  d4 R* e1 }+ k
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:165 z7 E* G" T0 V/ F. F. }$ U
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:79 C) e! j9 u7 @9 N
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
. s7 I1 ~) c9 M& s4 mgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)- E" _: R1 J  {( K
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)0 @( j) J6 G4 |8 U
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
' I, w1 C' A( x$ Q4 cgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
  q3 I! e& a; W; V* [* E1 l# Fgyp ERR! System Windows_NT 10.0.15063
! g: T" z6 b" Z% J5 n

( E6 U/ c# f. Q6 |; e解决办法  l' {1 X4 A$ K$ K; K
1、卸载nodejs重新安装一遍; l# ~7 Z% G5 E% c& g! n5 A) P/ I

3 u5 G" z% J  ^2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
+ T$ H7 e1 r6 k& P7 W9 a+ g) J3 h" ]3 t+ _7 D) s
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools0 @; U0 s& ]  E' _8 \. x
————————————————" \* f9 G+ l+ S. U$ T. B+ Y) t
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
3 j3 a4 \' O$ \8 r- {' U5 |原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

522

回帖

3494

积分

管理员

积分
3494
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.74 }9 v5 e* |8 C( ^

  d/ t! a% W% j. P3 f由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
2 M$ u* j: ?6 K7 Z; G5 I. d1 j: u' b1 I8 [3 a' u4 P' K
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
9 S" M/ o3 h2 I3 x/ S3 u# J& ^2 P————————————————8 A' |8 t/ _# d0 X) [0 a- q
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
' p! R& Q/ M7 T原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-11 16:02 , Processed in 0.014879 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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