找回密码
 立即注册
查看: 1499|回复: 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 | 显示全部楼层 |阅读模式
报错信息:7 S, E) C0 Z; ^: P0 J
```bash
6 Q1 X4 D. I# V* c2 ~: igyp ERR! find VS
% A7 e) c" {3 ]' \gyp ERR! find VS msvs_version not set from command line or npm config
7 j( L3 l+ s( I0 \+ q: G# q! igyp ERR! find VS running in VS Command Prompt, installation path is:
8 p# v! @+ w. k4 Ngyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"% w3 N0 n* G; [8 K4 i8 b0 P7 n4 d
gyp ERR! find VS - will only use this version
3 x# P" J9 A# ~- N, {. Qgyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
& x1 F) I' M2 b2 p# x2 ?gyp ERR! find VS looking for Visual Studio 2015
4 Z( O4 [) j- [& Rgyp ERR! find VS - not found
" d) X+ Z7 i, D) t  P* g* b& _- Ygyp ERR! find VS looking for Visual Studio 2013
# v) f+ ?' t5 {  L% c& ugyp ERR! find VS - not found9 V+ m- {) x" b& h7 A- X4 Q
gyp ERR! find VS
, B6 {$ g3 `) l$ Zgyp ERR! find VS **************************************************************9 f6 G- Z+ G7 \: x3 A
gyp ERR! find VS You need to install the latest version of Visual Studio
. D$ x, z1 o) Z/ jgyp ERR! find VS including the "Desktop development with C++" workload.2 H' G1 U5 [7 `- g0 q7 C$ J, Y
gyp ERR! find VS For more information consult the documentation at:
# ]: v/ R$ d: X1 }gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
8 R" s9 ^! y! i- \" |2 Ugyp ERR! find VS **************************************************************
" }5 ^6 t% D7 ?; s& \; Qgyp ERR! find VS# M4 _" E! y- X
gyp ERR! configure error
( l5 T* f- f* Q# j# Z; K4 Bgyp ERR! stack Error: Could not find any Visual Studio installation to use
- o4 ~0 Z  E. }% Q& n* ~1 U- |4 ngyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu3 W" h! |, T+ {- a0 F+ [" t
dio.js:121:47)8 p  f: g9 g  o3 ]+ g( l( Y
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16
  q# P0 }& v  f, M8 ?gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16) A& n$ K0 ?6 e5 g: p5 v! [
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
$ u  k3 N' `' O0 j" G2 R8 Ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:163 ]; Q1 s. [$ m7 G# b6 M+ V/ ]
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
- q* [  J+ q) {gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
/ P6 T5 w# C, s6 p0 ?gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16). u4 q  O3 l' Y6 M( i; |
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)# F+ d4 m+ r* A0 l- n, y9 i
gyp ERR! System Windows_NT 10.0.15063

8 P% }  c9 a9 v: R; _
# s1 ]5 H5 i: E解决办法
% ^8 `# `4 H5 Z6 y# c5 Q9 ]: Z1、卸载nodejs重新安装一遍7 f! C' |  M% i& [" o
; t& i2 Y0 B% ?5 E. N% F* P7 ~) J
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org6 i2 W! ]9 `% G: c' g8 s* j

$ i" x$ ~! J1 k$ k3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools. D2 A1 Z. N; c$ A! ?
————————————————( t& W! ?7 ?2 i$ x: E/ `
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
5 x+ `, o0 A. _4 q原文链接: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% H5 s& a+ E/ A+ x* J

: ^5 D0 w6 m) e3 W  K  m' w1 @由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
9 e& G7 ^5 B" {' D8 v) ]
$ Q/ x" D6 O- @$ M+ a然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!/ Y# K% ]1 K3 u/ X1 F3 d1 `
————————————————# ]4 T# U0 o! T) C4 d. c+ ?! y
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
. V# `4 j2 O7 v, J原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-7 21:36 , Processed in 0.015014 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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