卸载了Visual Studio后,在vscode中执行npm i或npm i --force时报错,该怎么解决?

卸载了Visual Studio后,在vscode中执行npm i或npm i --force时报错,该怎么解决?

  • 报错内容:
  • 原因
  • 解决办法

报错内容:

npm ERR! code 1
npm ERR! path E:\VScode\codeDate\yugan\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: E:\nodejs\node.exe E:\VScode\codeDate\yugan\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli 'E:\nodejs\node.exe',
npm ERR! gyp verb cli 'E:\VScode\codeDate\yugan\node_modules\node-gyp\bin\node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.18.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - executable path is "E:\python\python.exe"
npm ERR! gyp verb find Python - executing "E:\python\python.exe" to get version
npm ERR! gyp verb find Python - version is "3.7.4"
npm ERR! gyp info find Python using Python version 3.7.4 found at "E:\python\python.exe"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 16.18.1
npm ERR! gyp verb command install [ '16.18.1' ]
npm ERR! gyp verb install input version string "16.18.1"
npm ERR! gyp verb install installing version: 16.18.1
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check "installVersion"
npm ERR! gyp verb got "installVersion" 9
npm ERR! gyp verb needs "installVersion" 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 16.18.1
npm ERR! gyp verb build dir attempting to create "build" dir: E:\VScode\codeDate\yugan\node_modules\node-sass\build
npm ERR! gyp verb build dir "build" dir needed to be created? Yes
npm ERR! gyp verb find VS msvs_version not set from command line or npm config
npm ERR! gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp verb find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp verb find VS looking for Visual Studio 2015
npm ERR! gyp verb find VS - not found
npm ERR! gyp verb find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (E:\VScode\codeDate\yugan\node_modules\node-gyp\lib\find-visualstudio.js:122:47)npm ERR! gyp ERR! stack at E:\VScode\codeDate\yugan\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (E:\VScode\codeDate\yugan\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack at E:\VScode\codeDate\yugan\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack at E:\VScode\codeDate\yugan\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm ERR! gyp ERR! stack at E:\VScode\codeDate\yugan\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at E:\VScode\codeDate\yugan\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:410:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19044
npm ERR! gyp ERR! command "E:\nodejs\node.exe" "E:\VScode\codeDate\yugan\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd E:\VScode\codeDate\yugan\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.18.1
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1npm ERR! A complete log of this run can be found in:
npm ERR! E:\nodejs\node_cache_logs\2023-12-24T06_35_02_993Z-debug-0.log

一开始我看到这个报错写着这样:“npm ERR! gyp verb find Python checking if “python3” can be used”,这样:“npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the “Desktop development with C++” workload.”
报错时我觉得很懵逼,因为vscode中的报错和Visual Studioh、Python有什么关系,然后查找了很多资料之后发现:

原因

1.前端项目中有一些工具包或者处理器等的底层语言是用C++等写的,最初有些工具是用Ruby写的,为了提高性能和扩展性,Sass团队开发了一个名为LibSass的C/C++库,用于实现Sass的底层功能。比如SASS、LESS等;
2.如果你卸载了 Visual Studio,而在使用 VSCode 下载依赖时出现错误,是由于一些 Node.js 包需要依赖 Visual Studio 的构建工具链。当这些包尝试编译二进制插件时,缺少 Visual Studio 可能导致构建失败。

解决办法

1.首先执行命令:
需要以管理员身份打开命令框

npm install -g node-gyp

执行命令 npm install -g node-gyp 是为了全局安装 Node.js 模块 node-gyp。node-gyp 是一个用于编译和构建 Node.js C++ 插件的工具。

当你在项目中使用需要编译的 Node.js 模块时(例如 node-sass),这些模块通常需要通过 node-gyp 进行编译以生成适用于你的操作系统和 Node.js 版本的二进制文件。

通过在命令行中执行 npm install -g node-gyp 命令,你将全局安装 node-gyp 工具,使其可在任何项目中使用。这样,当你在项目中安装需要编译的 Node.js 模块时,它们将能够使用全局安装的 node-gyp 工具进行编译。

2.要全局安装 Windows Build Tools:Windows Build Tools 是一个针对 Node.js 的工具包,它提供了构建 Node.js 项目所需的编译工具链。我们通过运行以下命令全局安装 Windows Build Tools。
需要以管理员身份打开命令框

npm install --global windows-build-tools

它会自动下载和安装 Visual Studio Build Tools、Python 和其他构建所需的依赖,这样就解决了
Node.js 包需要依赖 Visual Studio 的构建工具链等问题了

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/576831.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ElasticSearch入门介绍和实战

目录 1.ElasticSearch简介 1.1 ElasticSearch(简称ES) 1.2 ElasticSearch与Lucene的关系 1.3 哪些公司在使用Elasticsearch 1.4 ES vs Solr比较 1.4.1 ES vs Solr 检索速度 2. Lucene全文检索框架 2.1 什么是全文检索 2.2 分词原理之倒排索引…

easypoi通过反射修改表头,poi,workbook修改表头

没废话上代码, 使用easypoi导出时一般会用到一个实体类 提供一个示例代码: 实体类: Data public class TestVO {private String id;Excel(name "字段1")private String findId1;Excel(name "字段2")private String fi…

Windows 10中查找文件的3种方法,就差不多够你查找想要的文件了

本文介绍了在Windows 10计算机上搜索文件的两种主要方法,以及对第三方搜索应用程序的建议和更好地搜索文件的有用提示。 使用任务栏搜索栏进行常规搜索 永久位于屏幕底部的搜索栏是大多数人的首选搜索方法,使用起来毫不费力。如果你不知道在哪里可以找…

2023航天推进理论基础考试划重点(W老师)绪论固体推进剂

1、推进系统的分类: 按工作原理分, 直接反作用发动机(喷气发动机) 火箭发动机、组合发动机、冲压发动机、涡轮喷气发动机、涡轮风扇发动机 间接反作用发动机 活塞式发动机、涡轮螺旋桨发动机、涡轮轴发动机、航空电动机 2、后面不细讲的火箭发动机要…

Windows系统重启Redis服务

Windows系统 在安装Redis的目录下打开终端 执行 redis-cli.exe shutdown先停止 Redis 服务 然后 执行 redis-server.exe启动Redis服务

浅谈Dubbo核心概念及架构流程

浅谈Dubbo核心概念及架构流程 前言重要概念1、SPI2、ServiceBean3、URL4、Invoker 整体流程1、架构图2、调用链路 笔者碎碎言,我们学习Dubbo应该学的是什么? 笔者是一名业务开发,认为一切目的都要为我们的目标服务,即日常工作有帮…

医院智慧能源管理平台,为医疗机构高效控能!

随着医院的不断扩大与发展,能源问题日益严重。大型医院能耗计量点位繁多,数据采集方式落后,难以保证计量管理的准确性与科学性。为了对医院能耗进行精细化管理,实时监测用能情况,需要建议一个完善的监管体系。基于能源…

docker 安装mysql 8.0.35

1.拉取镜像 docker pull mysql:8.0.35 2.创建相关挂载目录与文件 mkdir -p /opt/mysql8/conf mkdir -p /opt/mysql8/data mkdir -p /opt/mysql8/logs 或者:mkdir -p /opt/mysql8/{data,conf,logs,mysqld,mysql-files} 文件与文件夹授权:chmod -R 775 /opt/mysql8/* 3.运…

软件开发有哪些基本常识?

软件开发的定义:软件开发是指使用计算机语言编写程序,将计算机硬件与软件相结合,实现某种功能的过程。 软件开发的流程:通常包括需求分析、设计、编码、测试、部署和维护等环节。 需求分析:在软件开发过程中&#xff…

Java Heap Space堆内存异常处理

Heap Space问题是Java开发中常见的内存溢出问题之一,我们需要理解其原因和表现形式,然后通过优化代码、增加JVM内存和使用垃圾回收机制等方法来解决。 场景 新增数据,富文本插入多张图片,总共总共大小6.6MB,提交报50…

java期末复习笔记

java期末复习笔记 课程大纲java开发入门java发展历程(可能)java特点(可能)java版本(可能)java运行过程java类结构(注意编程题)java环境的配置 java编程基础(选择填空&…

【XML】TinyXML 详解(一):介绍

【C】郭老二博文之:C目录 1、简介 优点: TinyXML 是一个简单、小型的 C XML 解析器,可以轻松集成到项目中。 TinyXML 解析 XML 文档,并根据该文档构建可读取、修改和保存的文档对象模型 (DOM) TinyXML 是在 ZLib 许可下发布的&a…

计算机毕业设计------SSM网上超市购物商城管理系统

项目介绍 本项目分为前后台,分为普通用户、管理员两种角色。前台普通用户登录,后台管理员登录; 管理员角色包含以下功能: 登录页面,用户查看,一级分类管理,二级分类管理,商品管理,查看订单,留言管理等功能。 用户角色包含以下功…

如何使用JuiceSSH实现手机端远程连接Linux服务器

文章目录 1. Linux安装cpolar2. 创建公网SSH连接地址3. JuiceSSH公网远程连接4. 固定连接SSH公网地址5. SSH固定地址连接测试 处于内网的虚拟机如何被外网访问呢?如何手机就能访问虚拟机呢? cpolarJuiceSSH 实现手机端远程连接Linux虚拟机(内网穿透,手机端连接Linux虚拟机) …

Linux---命令行参数+环境变量

一、命令行参数 int main(int argc,char*argv[]) {//...return 0; } 不知道有没有人见过这样的主函数,它带了两个参数,argv接收的参数就叫做命令行参数,因为它的参数是从命令行来的,给大家演示一下,大家就懂了 命令行…

算法基础之数字三角形

数字三角形 核心思想&#xff1a;线性dp 集合的定义为 f[i][j] –> 到i j点的最大距离 从下往上传值 父节点f[i][j] max(f[i1][j] , f[i1][j1]) w[i][j] 初始化最后一层 f w #include <bits/stdc.h>using namespace std;const int N 510;int w[N][N],f[N][…

java“俄罗斯方块”

首先新建议一个包为Tetris &#xff08;俄罗斯方块&#xff09; 类名也叫做Tetris&#xff1b; 代码运行&#xff1a; package Tetris; import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; import java.awt.event.KeyEvent; import java.aw…

腾讯云服务器免费再领一台是什么意思?

腾讯云免费再领一台轻量应用服务器是什么意思&#xff1f;是指在腾讯云买赠专区活动 https://curl.qcloud.com/oRMoSucP 就是轻量应用服务器买一年&#xff0c;购买的时候可以选择“送同配置3个月”&#xff0c;也可以选择“免费续3个月”&#xff0c;阿腾云atengyun.com活动打…

创新5.1 7.1KX声卡驱动

———————KX声卡驱动——————— &#x1f384;声卡外观 &#x1f384;声卡介绍 &#x1f388;创新5.1 7.1声卡是网络直播&#xff0c;娱乐&#xff0c;唱歌&#xff0c;交友等一种音效内置声卡 &#x1f384;型号 &#x1f388;创新5.1内置声卡sb0060 0090 sn0105…

Python中的tuple类型详解

在Python中&#xff0c;元组&#xff08;tuple&#xff09;是一种不可变的序列类型&#xff0c;可以包含多个值&#xff0c;这些值可以是不同类型的。元组在创建后不能修改&#xff0c;这意味着你不能添加、删除或更改元组中的元素。下面是有关元组的一些基本操作&#xff1a; …