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

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

[复制链接]

340

主题

530

回帖

3538

积分

管理员

积分
3538
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
3 }! f: Q0 Y. N$ K
```bash
) u/ ^* S, y- ]' I' Q4 V& y# Bgyp ERR! find VS. M( Q7 B1 [( r) g$ |& E
gyp ERR! find VS msvs_version not set from command line or npm config
. \2 ]$ U0 c1 C: t! N% hgyp ERR! find VS running in VS Command Prompt, installation path is:
4 v- }& R  b2 Wgyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"8 g9 C: X- N4 b4 E8 g
gyp ERR! find VS - will only use this version* _# U: ~1 m; q0 S: Z
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer& D" H+ f1 H2 E' j, v
gyp ERR! find VS looking for Visual Studio 20151 T* C9 d) d4 f3 c+ ]
gyp ERR! find VS - not found( r) e& R2 B3 b  ]
gyp ERR! find VS looking for Visual Studio 2013
/ h% A1 a8 w6 |+ R; _" D) F. rgyp ERR! find VS - not found
* m2 f+ O# Q" i) u6 f# L; T& Z% Ugyp ERR! find VS6 A- D  _0 C1 g& |1 \; u
gyp ERR! find VS **************************************************************
- S: J4 H  i/ D% y+ Pgyp ERR! find VS You need to install the latest version of Visual Studio
2 s7 h# f7 L% Z: wgyp ERR! find VS including the "Desktop development with C++" workload.7 x9 m' L. N: |; u7 f) @; @
gyp ERR! find VS For more information consult the documentation at:8 V" v- M$ t" l0 _: h/ u- i
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
1 D4 u6 H0 N0 N* G+ xgyp ERR! find VS **************************************************************
; q# W9 w" @" D3 C: W6 egyp ERR! find VS
) ^9 O2 Q0 p5 a+ h2 ogyp ERR! configure error* o& f5 b; j" B5 x4 e8 Y) [
gyp ERR! stack Error: Could not find any Visual Studio installation to use
8 f, O* }* V& [' q. E( b5 ~gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu
, i, {, o6 L( ?' `; ~, o( z# a" adio.js:121:47)( y3 x8 ^9 g( _# Y9 i- H8 L
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
! j7 H- j# Q* j$ ~0 tgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
7 Y% l  h' Y1 l$ d( zgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
8 o) D$ e9 R; ?' }7 l! agyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:164 k0 F1 N: G" W5 j
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)' `8 D+ x3 ]! B2 D! Y6 T
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
& r9 [: R1 D8 F( Q6 R6 `gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)$ [* m, K+ [, z8 t) R: h
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
0 y- t" n# |" i8 U& }$ wgyp ERR! System Windows_NT 10.0.15063
0 m; N5 e+ S; H5 l( F. @$ {& e

; T& A: z; C$ W, H/ H4 O解决办法. @2 ]! T8 m1 t3 `
1、卸载nodejs重新安装一遍
& p9 f4 q7 n# Z; \2 f/ X* L; F4 d; }- l9 Q/ e% i: N9 I+ J6 g( D
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
  L# L& m+ ^- D2 {
( v0 B3 i5 w% J; ~) k3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools9 \5 h/ q, N9 X1 ]. s# f% G. D3 z! ~
————————————————0 Y" G4 ~& U) U, c2 v
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。& b5 ]# e  v1 i) H* B, D
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

530

回帖

3538

积分

管理员

积分
3538
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7  y) ^2 g# `# O) |' T

+ m# V9 k5 O. `  x由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。0 Q( k/ ]( c6 G$ o% q
) `7 l3 a, t. W0 W: z% |' G
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!' I5 A/ W3 _; X
————————————————. E, k# f) {1 f. V
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。6 }; m; }, m$ p8 K) Y9 g: o
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-22 11:46 , Processed in 0.014695 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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