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

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

[复制链接]

340

主题

522

回帖

3498

积分

管理员

积分
3498
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
% {' t; o- q* C2 n! `
```bash
, Y7 k) |" T% [  }gyp ERR! find VS
8 ?5 ^" O' M8 \9 H# Ggyp ERR! find VS msvs_version not set from command line or npm config( e4 O2 O; V, O8 y4 a# P
gyp ERR! find VS running in VS Command Prompt, installation path is:
/ ~' N9 q9 C2 C. W; X- k% u6 ?gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"# ]# n+ R& R) \6 H
gyp ERR! find VS - will only use this version
1 B& B( k$ b8 }0 j1 @3 e% {gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer# x; {5 Y  S; V" V6 ]* H
gyp ERR! find VS looking for Visual Studio 2015! E, R7 }  J. D
gyp ERR! find VS - not found
% q/ u& r9 s. `gyp ERR! find VS looking for Visual Studio 2013
& }: U2 n5 G$ wgyp ERR! find VS - not found
5 @6 f2 O- o0 o( d7 |" {9 mgyp ERR! find VS9 m- |$ s" \8 s- h# j
gyp ERR! find VS **************************************************************6 j, y% K, k! v  x' ]. l" G% d
gyp ERR! find VS You need to install the latest version of Visual Studio- d7 n1 [8 D2 Y
gyp ERR! find VS including the "Desktop development with C++" workload.4 X5 f1 J/ e5 q+ N
gyp ERR! find VS For more information consult the documentation at:$ ]4 f$ `( X3 ]# p  I. n
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
  y; v5 r7 \8 g. u- o# d5 S* ^! [) Rgyp ERR! find VS **************************************************************" s( J. K" B6 H
gyp ERR! find VS0 |4 ]1 f8 E+ f5 q
gyp ERR! configure error# w/ N* p% P! r
gyp ERR! stack Error: Could not find any Visual Studio installation to use
- o- U; T  O3 o1 m$ Ngyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu+ \5 R9 g# Y2 Y& B& j8 d# T3 }+ p
dio.js:121:47)7 g" ]% l# P9 g1 V* ~, R
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:16" h8 e. Y0 y/ _5 a" r
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:169 I. ~  _; H) l9 }! K
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
7 h  U8 h0 B2 ^6 D6 v$ Y+ ~7 Ggyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:16
! _* k; b6 z9 k6 u# Pgyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
9 ^: a1 U  L& y' ^# o1 ^gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
& J3 h; }0 s1 J- M( r" h# cgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)% Z! K' K' o9 c/ @, s2 D' b4 G
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
7 G9 {/ Y9 _$ v5 E- Y9 Z8 j# Vgyp ERR! System Windows_NT 10.0.15063
! ]/ Q  n9 d$ b. U0 p% ~7 k7 A

: Y" U4 M( `$ q) V5 P0 [. l解决办法7 a4 a& \6 n1 v' X% t2 c' T. o7 R
1、卸载nodejs重新安装一遍7 n& `, p/ A' a1 N

, o' \  V) s+ q' z4 p( A1 D- z2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
; L' P- `, r" X# F
/ {3 g. v# y- J$ _; G$ c3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools* t! o# q+ S' g/ \! V" f
————————————————
# M6 y8 h2 N! A' c: u版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。6 I0 p6 v" ]" k/ M8 A, K
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

340

主题

522

回帖

3498

积分

管理员

积分
3498
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.70 Q6 J( E/ G$ I! G( Y4 R
* Y- L# {2 d5 G6 C6 E
由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。
6 U7 ?2 a5 Y( k- i+ w  }" G" X0 E- C& }" D( G: G/ R
然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!, y' S% A" A. B! Y4 b
————————————————
1 H: I. Z" \* a9 g版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
* f7 T; r& ], X' `原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-13 17:53 , Processed in 0.020614 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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