当前位置: 首页 > news >正文

卸载了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 的构建工具链等问题了

相关文章:

卸载了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 np…...

渗透测试 | 信息收集常用方法合集

目录 一、关于域名 1.子域名收集 a.搜索引擎查找 b.在线查询 c.工具 d.SSL/TLS证书查询 2.端口型站点收集 3.目录文件扫描 a.目录扫描工具 b.github搜索 c.google搜索 d.在线网站 e.文件接口工具 4.旁站和C段 a.旁站查询 b.C段查询 5.网站技术架构信息 a.基础…...

使用 ElementUI 组件构建无边框 Window 桌面应用(WinForm/WPF)

生活不可能像你想象得那么好,但也不会像你想象得那么糟。 我觉得人的脆弱和坚强都超乎自己的想象。 有时,我可能脆弱得一句话就泪流满面;有时,也发现自己咬着牙走了很长的路。 ——莫泊桑 《一生》 一、技术栈 Vite + Vue3 + TS + ElementUI(plus) + .NET Framework 4.7.2…...

JavaScript中数组的方法和函数作用域问题

1 -函数作用域问题-: 函数的外层作用域,在函数创建时就已确定,和函数的调用位置无关 var name 嘿嘿;// 函数的外层作用域,在函数创建时就已确定,和函数的调用位置无关// JS中的作用域被称为 词法作用域function fn() {console.…...

nodejs设置x-xss-protection解决xss问题

在Node.js中设置X-XSS-Protection可以通过使用helmet库来完成。 首先,确保已经安装了helmet库。如果没有安装,可以运行以下命令进行安装: npm install helmet --save 然后,在你的Node.js应用程序中引入并配置helmet库&#xff…...

C/C++不同整数类型的区别

在C/C中涉及的整数相关的类型大致有如下几种: char、unsigned charshort、unsigned shortint、unsigned intlong、unsigned longlong long、unsigned long longint8_t、uint8_tint32_t、uint32_tint64_t、uint64_tDWORDDWORD32、DWORD64size_t、ssize_tSIZE_T、SSI…...

如何理解JDK、JRE、JVM区别与联系

摘要:JDK是 Java 语言的软件开发工具包(SDK)。在JDK的安装目录下有一个jre目录,里面有两个文件夹bin和lib,在这里可以认为bin里的就是jvm,lib中则是jvm工作所需要的类库,而jvm和 lib合起来就称为jre。 一、JDK JDK(Ja…...

用友GRP-U8 SmartUpload01 文件上传漏洞

漏洞描述 用友GRP-U8行政事业内控管理软件是一款专门针对行政事业单位开发的内部控制管理系统,旨在提高内部控制的效率和准确性。该软件/u8qx/SmartUpload01.jsp接口存在文件上传漏洞,未经授权的攻击者可通过此漏洞上传恶意后门文件,从而获取…...

react 路由v6

这里是区别:V5 vs V6 这里是官网:可以查看更多高级属性 一、基本使用: 1、配置文件 src/routes/index import React from "react";const Home React.lazy(() > import("../Pages/Home")); const About React.laz…...

rpc【通义】rpc原理【gpt】

一 rpc RPC(Remote Procedure Call,远程过程调用)是一种编程技术,它允许在分布式系统中的一个程序像调用本地函数一样调用另一个程序(位于不同的机器或进程中)的函数或方法。RPC的主要目标是隐藏网络通信的…...

Leetcode 2973. Find Number of Coins to Place in Tree Nodes

Leetcode 2973. Find Number of Coins to Place in Tree Nodes 1. 解题思路2. 代码实现 题目链接:2973. Find Number of Coins to Place in Tree Nodes 1. 解题思路 这道题思路上其实挺简单的,就是一个遍历的思路,找到每一个点对应的子树当…...

如何调动销售人员使用CRM的积极性?

CRM系统在销售人员眼中是流程监管工具也是单调枯燥的操作空间,如何让销售爱上CRM系统?1.让CRM简化销售工作;2.智能提醒销售各项事务;3.让CRM界面更加丰富多彩,通过这些方法帮助销售经理轻松管理团队,销售对…...

数值分析期末复习

第一章 科学计算 误差 解题步骤 x : 真实值 x:真实值 x:真实值 x ∗ : 近似值 x^*:近似值 x∗:近似值 先求绝对误差 e ∗ e^* e∗: x − x ∗ x - x^* x−x∗ 绝对误差限是 ∣ x − x ∗ ∣ ≤ ε |x - x^{*}| \le \varepsilon ∣x−x∗∣≤ε 求相对误差限: ∣ x − x ∗…...

k8s的探针

一、探针原理 分布式系统和微服务体系结构的挑战之一是自动检测不正常的应用程序,并将请求(request)重新路由到其他可用系统,恢复损坏的组件。健康检查是应对该挑战的一种可靠方法。使用 Kubernetes,可以通过探针配置运…...

Python 爬虫之下载视频(五)

爬取第三方网站视频 文章目录 爬取第三方网站视频前言一、基本情况二、基本思路三、代码编写四、注意事项(ffmpeg)总结 前言 国内主流的视频平台有点难。。。就暂且记录一些三方视频平台的爬取吧。比如下面这个: 一、基本情况 这次爬取的方…...

Gradle下载地址

Gradle下载地址 Gradle是一个基于JVM的构建工具,是一款通用灵活的构建工具,Gradle也是第一个构建集成工具,与ant、maven、ivy有良好的相容相关性。支持maven, Ivy仓库,支持传递性依赖管理,而不需要远程仓库…...

顺序表的实现(头插、尾插、头删、尾删、查找、删除、插入)

目录 一. 数据结构相关概念​ 二、线性表 三、顺序表概念及结构 3.1顺序表一般可以分为: 3.2 接口实现: 四、基本操作实现 4.1顺序表初始化 4.2检查空间,如果满了,进行增容​编辑 4.3顺序表打印 4.4顺序表销毁 4.5顺…...

VMware虚拟机安装Ubuntu系统教程

所使用的文件如下: VMware Workstation 17 Pro ubuntu-22.04.3-desktop-amd64.iso 一、ubuntu 命名规则及各版本一览表 1.ubuntu 命名规则: 例如:ubuntu 16.04 LTS 是长期维护版本;ubuntu 17.04 是新特性版本 前两位数字为发…...

41 sysfs 文件系统

前言 在 linux 中常见的文件系统 有很多, 如下 基于磁盘的文件系统, ext2, ext3, ext4, xfs, btrfs, jfs, ntfs 内存文件系统, procfs, sysfs, tmpfs, squashfs, debugfs 闪存文件系统, ubifs, jffs2, yaffs 文件系统这一套体系在 linux 有一层 vfs 抽象, 用户程序不用…...

C++面试宝典第9题:找出第K大元素

题目 给定一个整数数组a,同时给定它的大小N和要找的K(1 <= K <= N),请根据快速排序的思路,找出数组中第K大的数(保证答案存在)。比如:数组a为[50, 23, 66, 18, 72],数组大小N为5,K为3,则第K大的数为50。 解析 这道题主要考察应聘者对于快速排序的理解,以及实…...

“马屁精”李白

“李白一斗诗百篇&#xff0c;长安市上酒家眠。天子呼来不上船&#xff0c;自称臣是酒中仙。”这是诗圣杜甫笔下的李白&#xff0c;也是我们脑海里坚信无二的李白。恃才傲物又狂放不羁的诗仙&#xff0c;怎么会低眉顺眼地去拍人马屁呢&#xff1f; 但我要说的是&#xff0c;人…...

python之glob的用法

目录 获取特定扩展名的所有文件 获取特定目录下的所有文件 递归获取所有文件 转义特殊字符 iglob glob 是 Python 中用于文件模式匹配的一个模块。它使用 Unix shell-style 的通配符来进行匹配&#xff0c;并返回所有匹配的文件路径列表。 下面是一些 glob 的基本用法&am…...

【adb】电脑通过ADB向手机传输文件

具体步骤如下&#xff1a; Step1 下载ADB工具 下载最新版本的 ADB工具 !!! 注意&#xff1a;一定要是最新版本的ADB&#xff0c;否则很可能导致无法识别到手机。 将下载的ADB解压以后的文件如下图所示&#xff1a; Step2 添加环境变量 将 ADB的路径 D:\platformtools &…...

npm的常用使用技巧

npm是一个强大的工具&#xff0c;可以帮助你管理Node.js项目中的依赖项。以下是一些有用的npm使用技巧&#xff1a; 使用npm install命令&#xff1a;这个命令可以安装项目的依赖项。如果你想安装一个特定的版本&#xff0c;你可以使用npm install <package><version…...

【网络奇遇记】揭秘计算机网络的性能指标:速率|带宽|吞吐量|时延

&#x1f308;个人主页&#xff1a;聆风吟 &#x1f525;系列专栏&#xff1a;网络奇遇记、数据结构 &#x1f516;少年有梦不应止于心动&#xff0c;更要付诸行动。 文章目录 &#x1f4cb;前言一. 速率1.1 数据量1.2 速率 二. 带宽三. 吞吐量四. 时延4.1 发送时延4.2 传播时延…...

ACM中算法时间约束

ACM中算法时间约束 一般ACM竞赛C/C的时间限制是一秒&#xff0c;因此可以根据题目数据来推断该题所使用的算法。 算法的时间复杂度在 1 0 7 10^7 107左右合适&#xff0c;最多不能超过 1 0 8 10^8 108&#xff0c; O ( n ) O(n) O(n)的极限就在 1 0 8 10^8 108左右。 问题规…...

C++11的列表初始化和右值引用

目录 前言 一、C11的简介 二、C11的小故事。 三、统一的列表初始化 1.列表初始化 2.initializer_list 四、右值引用 1.什么是左值 2.什么是右值 3.右值引用写法 4.右值的分类 5.右值引用的作用 6.STL容器中的右值引用 7.万能引用 总结 前言 C11相较于之C98&…...

千帆起航:探索百度智能云千帆AppBuilder在AI原生应用开发中的革新之路

千帆起航&#xff1a;探索百度千帆AppBuilder在AI原生应用开发中的革新之路 1.揭开帷幕&#xff0c;大模型第二次战役 自从 ChatGPT 横空出世后&#xff0c;一石激起千层浪&#xff0c;人工智能也正在从感知理解走向生成创造&#xff0c;这是一个关键里程碑。生成式大模型完成…...

RevIT™ AAV Enhancer, 提高AAV产量的又一利器!

腺相关病毒 (AAV) 是基因治疗中使用最广泛的传递机制。近年来&#xff0c;基于AAV病毒所开发的基因疗法的研发及临床试验注册数量也呈指数级增长。截止本文撰写之时&#xff0c;美国食品和药物管理局已批准五项AAV疗法&#xff0c;也是全球市场上最为昂贵的药物&#xff0c;其中…...

Kubectl 部署有状态应用(下)

接上文 《Kubectl 部署有状态应用&#xff08;上&#xff09;》创建完StatefulSet后&#xff0c;本文继续介绍StatefulSet 扩展、更新、删除等内容。 StatefulSet 中的 Pod 验证序数索引和稳定的网络身份 StatefulSet 中的 Pod 具有唯一的序数索引和稳定的网络身份。 查看 …...