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

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

[复制链接]

334

主题

517

回帖

3396

积分

管理员

积分
3396
QQ
发表于 2023-8-28 23:03:22 | 显示全部楼层 |阅读模式
报错信息:
; v0 T, e0 v6 e4 {) b8 z3 j) H5 u
```bash
* s, b7 Z& k3 k* `, q9 Cgyp ERR! find VS
& a- y3 [' P* |6 @* S# {8 \0 zgyp ERR! find VS msvs_version not set from command line or npm config1 ~5 h8 `% w3 ?
gyp ERR! find VS running in VS Command Prompt, installation path is:$ z% U4 M9 g2 p- e& x
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017"
% `' f' o, q& m  m. m3 Kgyp ERR! find VS - will only use this version! R8 k5 O8 p& w- Q1 V6 }4 g
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
: e& ?* {. T7 T5 C$ cgyp ERR! find VS looking for Visual Studio 20156 V8 C- r/ Y5 t% f# m  @
gyp ERR! find VS - not found
# O  U5 K( M8 X. vgyp ERR! find VS looking for Visual Studio 2013
& y- d: ?2 L5 j4 Q1 w; A; J8 [5 Fgyp ERR! find VS - not found
& F0 k9 J8 ?3 K( ?% o* k0 Zgyp ERR! find VS( U% q' d7 h* [% T
gyp ERR! find VS **************************************************************
4 p5 ]- I+ X9 U/ s3 \gyp ERR! find VS You need to install the latest version of Visual Studio
4 B' Z( ?2 V  K! Ngyp ERR! find VS including the "Desktop development with C++" workload." u' d6 L9 |9 p" k) a: L
gyp ERR! find VS For more information consult the documentation at:, ?9 z5 U$ d8 A
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows. ?& H( E) A: T, D) r% C6 @
gyp ERR! find VS **************************************************************
* n! e: y2 T! n9 Vgyp ERR! find VS
9 A% G* D4 W# Mgyp ERR! configure error3 N, U, \- B! i& _( I
gyp ERR! stack Error: Could not find any Visual Studio installation to use6 p& g- J& `3 ?: r# h& \
gyp ERR! stack     at VisualStudioFinder.fail (D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstu" U$ @$ O' w/ [
dio.js:121:47)/ Z6 E: _/ i$ p/ P" v
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:74:164 j# v+ z7 D% H% w( ^; k% m0 A
gyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\find-visualstudio.js:372:16
, y& f( z" A. z" E! ~1 I6 hgyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:54:7
4 k1 M% I6 _  @/ g* m/ Ugyp ERR! stack     at D:\rymcu\electron-serialport\node_modules\node-gyp\lib\util.js:33:163 N: c5 j7 Y# G7 N' `
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5): J# [8 B" j. }( Q% ?
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
$ ]& S9 g# @3 W+ [. k% Kgyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
+ c8 z% v7 T; R" `, ~: e1 qgyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
, I2 a' S: H$ E9 F! vgyp ERR! System Windows_NT 10.0.15063

  u' {- n4 P; t# c8 b5 s' ]4 }, H2 k6 _0 K  a5 a
解决办法
. V5 s) ^& p( y5 S; {1、卸载nodejs重新安装一遍
  g- Q( c  ^# o5 s" M) M; y2 @
2、设置淘宝镜像 npm config set registry https://registry.npm.taobao.org
& q$ L0 ?+ B7 P- ^, A% s+ v/ J5 J" n' S+ w. |* J: v7 }% a" a  q( I
3、安装nodejs所需的环境(Visual Studio XX、python什么鬼的),执行这个命令会自动检测并帮你安装好,npm install --g --production windows-build-tools: d+ t$ v  f( w2 ?
————————————————
0 u% P4 g2 H$ u版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。) x9 H  ~7 a) |- n
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

334

主题

517

回帖

3396

积分

管理员

积分
3396
QQ
 楼主| 发表于 2023-8-28 23:03:39 | 显示全部楼层
4、关键所在!!!执行编译时指定python版本,npm install --python=python2.7
/ ~* @6 h  z/ N" {0 M6 f+ Y& B: G5 k
; W% X8 ?3 U7 G0 t' k由于我的电脑之前安装过python3版本,并且设置了环境变量,所以npm install会找我默认的python,所以执行时指定nodejs只支持的python2版本。' U; O& a) X) e8 D

& G( R, D+ X* W/ {+ S7 y) U然后,神奇的事情到了,我把编译包modules删掉后重新编译(这次不指定python2版本直接npm install),居然奇迹般的又没有报错!!!想不通。。。难道npm会将上次编译成功的配置保存下来??算了不纠结了哭泣!
5 B8 H' z& v6 j+ g! r5 [————————————————1 H" d0 R  Q  E: R! Z% \% U- m
版权声明:本文为CSDN博主「一点一滴成长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。0 b: F. V) }- E' y
原文链接:https://blog.csdn.net/qq_39946015/article/details/127351920
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-3 13:59 , Processed in 0.085858 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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