knowledge-vault/sources/references/开发笔记/Nodejs/安装Bun和UV.md

90 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## install Bun v1.2.13
```bash
curl -fsSL https://bun.sh/install | bash
# or you can use npm
# npm install -g bun
```
Windows:
```bash
powershell -c "irm bun.sh/install.ps1|iex"
```
To upgrade to Bun v1.2.13:
```bash
bun upgrade
```
## Install uv 0.7.5
Install prebuilt binaries via shell script
```bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.7.5/uv-installer.sh | sh
```
Install prebuilt binaries via powershell script
```bash
powershell -ExecutionPolicy Bypass -c "irm https://github.com/astral-sh/uv/releases/download/0.7.5/uv-installer.ps1 | iex"
```
---
## 调试Bun
```bash
cd C:\Users\wangq\.cherrystudio\bin
bun x -y @modelcontextprotocol/server-filesystem
cmd /k npx -y @modelcontextprotocol/server-filesystem "D:/AI/ai-data"
```
## 当在windows环境的CMD下执行“bun x -y @modelcontextprotocol/server-filesystem”这个命令报错error: CERT_HAS_EXPIRED downloading package manifest @modelcontextprotocol/server-filesystem 可能是什么原因
这个错误 `error: CERT_HAS_EXPIRED downloading package manifest @modelcontextprotocol/server-filesystem` 通常是因为 Bun 在下载依赖包时,访问的远程服务器的 SSL 证书已经过期,导致无法建立安全连接。
**常见原因:**
1. 你的本地系统时间不正确,导致 SSL 校验失败。
2. 依赖的 npm registry 或第三方源的证书确实已经过期(比如淘宝源、私有源等)。
3. 你的网络环境存在代理或中间人,拦截了 SSL 证书。
4. Bun 版本较老,内置的 CA 证书未及时更新。
**解决办法:**
1. **检查本地时间**
确保 Windows 系统时间和时区设置正确。
2. **切换 npm registry**
尝试切换到官方 npm 源,避免使用镜像源:
```bash
bun config set registry https://registry.npmjs.org/
```
3. **升级 Bun**
你已经在用 v1.2.13,但可以再次尝试升级:
```bash
bun upgrade
```
4. **检查网络代理**
如果你使用了代理,尝试关闭代理或更换网络环境。
5. **临时忽略证书校验(不推荐,仅测试)**
这种方式有安全风险,仅用于排查问题:
```bash
set NODE_TLS_REJECT_UNAUTHORIZED=0
bun x -y @modelcontextprotocol/server-filesystem
```
用完后请务必恢复环境变量。
---
**建议优先检查系统时间和 registry 设置。如果依然不行,建议尝试用 npm/yarn/pnpm 安装该包,看是否同样报错,以判断是 Bun 问题还是网络/源问题。**