Daotin

安装一个依赖失败如何分析

前端

示例:当 clone vscode 源码后,使用 yarn 安装报错:

plain text
error E:\whty-code\vscode\node_modules\@vscode\ripgrep: Command failed.
Exit code: 1
Command: node ./lib/postinstall.js
Arguments:
Directory: E:\whty-code\vscode\node_modules\@vscode\ripgrep
[1/22] ⠂ @parcel/watcher

思路分析

1、Google 搜索 vscode yarn install error @vscode/ripgrep

经过查找几个网页后,并未解决

2、在 Github issues 中搜索 ripgrep error Command failed

依然未找到答案,但是有了思路 3

3、在一个空文件夹单独安装看是否报错

plain text
yarn add @vscode/ripgrep

依然报错,切换 registry 也是一样。

4、尝试 使用 npm 安装

plain text
npm i @vscode/ripgrep

依然报错,但是生成了错误日志。

5、复制到 ChatGPT 询问,让其分析错误原因

plain text
请帮我分析下下面使用npm i @vscode/ripgrep 安装失败的log:

xxx

6、问题解决

ChatGPT 分析说:下载过程中出现了错误,具体错误信息是关于 oh-my-posh 的。看起来你的 PowerShell 配置文件 (C:.PowerShell_profile.ps1) 中有一个命令 oh-my-posh,但系统找不到这个命令。

最后,删掉相关配置即可。

Related posts