From 7f14d85df0b1553f5899f4d94e0cbd5c0fdd8689 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 7 Oct 2026 08:54:46 +0800 Subject: [PATCH] docs: default to a user-level npm prefix (~/.local) for installs --- README.md | 13 ++++++++++++- README.zh-CN.md | 8 +++++++- src/update.ts | 5 ++++- website/blog/posts/2026-10-08_meet-bili.md | 2 +- website/blog/posts/2026-10-08_meet-bili.zh.md | 2 +- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2687c51605..7e1da35a67 100644 --- a/README.md +++ b/README.md @@ -129,11 +129,22 @@ Pick by your client: ## Install +Linux / macOS — one-time setup with a user-level npm prefix (no `sudo`, and `bili`'s +self-update never hits permission errors): + ```bash +npm config set prefix "$HOME/.local" +export PATH="$HOME/.local/bin:$PATH" # add this line to ~/.bashrc or ~/.zshrc too npm install -g billion-context ``` -This installs the `bili` command (`bili-proxy` is kept as an alias). +On nvm or Homebrew Node the default prefix is already user-owned — a plain +`npm install -g billion-context` works as-is. On Windows the default prefix +(`%APPDATA%\npm`) is also user-writable — plain `npm install -g billion-context`. + +This installs the `bili` command (`bili-proxy` is kept as an alias). Hitting +`EACCES` with an old root-owned prefix? Run the two prefix lines above, then +reinstall — that is the permanent fix; avoid `sudo`. ## Quickstart diff --git a/README.zh-CN.md b/README.zh-CN.md index f17502cf66..11e0a20dc4 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -131,11 +131,17 @@ QQ群: ## 安装 +Linux / macOS —— 一次性配置用户级 npm prefix(全程不需要 `sudo`,`bili` 自更新也不会再遇到权限问题): + ```bash +npm config set prefix "$HOME/.local" +export PATH="$HOME/.local/bin:$PATH" # 这行也请写进 ~/.bashrc 或 ~/.zshrc npm install -g billion-context ``` -这会安装 `bili` 命令(`bili-proxy` 保留为别名)。 +用 nvm 或 Homebrew Node 的,默认 prefix 本来就属于当前用户,直接 `npm install -g billion-context` 即可;Windows 的默认 prefix(`%APPDATA%\npm`)同样用户可写,直接 `npm install -g billion-context`。 + +这会安装 `bili` 命令(`bili-proxy` 保留为别名)。旧装的是 root 属主的 prefix、现在报 `EACCES`?执行上面两行 prefix 命令后重装即可根治——不要用 `sudo`。 ## 快速上手 diff --git a/src/update.ts b/src/update.ts index 1219bf9584..14b64df18f 100644 --- a/src/update.ts +++ b/src/update.ts @@ -397,7 +397,10 @@ export function backoffMs(count: number): number { function remediationHint(error: string): string { if (/not writable/i.test(error)) { - return "the install dir is not writable by this user. Fix its ownership/permissions, point npm at a user-writable prefix and reinstall (npm install -g billion-context), or disable auto-update (config autoUpdate:false / env ACP_AUTO_UPDATE=0)"; + if (process.platform === "win32") { + return "the install dir is not writable by this user. On Windows the default npm prefix (%APPDATA%\\npm) is user-writable \u2014 repair that dir's ownership/permissions and reinstall (npm install -g billion-context), or disable auto-update (config autoUpdate:false / env ACP_AUTO_UPDATE=0)"; + } + return "the install dir is not writable by this user. Fix its ownership/permissions, or move to a user-level prefix \u2014 npm config set prefix \"$HOME/.local\" (then put \"$HOME/.local/bin\" on PATH) and npm install -g billion-context \u2014 or disable auto-update (config autoUpdate:false / env ACP_AUTO_UPDATE=0)"; } if (/git working tree/i.test(error)) { return "this copy runs from a source checkout. Install globally instead (npm install -g billion-context) so auto-update has a writable target"; diff --git a/website/blog/posts/2026-10-08_meet-bili.md b/website/blog/posts/2026-10-08_meet-bili.md index b9568358b5..7b9f69057a 100644 --- a/website/blog/posts/2026-10-08_meet-bili.md +++ b/website/blog/posts/2026-10-08_meet-bili.md @@ -26,6 +26,6 @@ The numbers on the front page are production data: 174,327 model calls, 18.8B cu ## Where it runs -One npm package, Node 22+, MIT license. Install with `npm install -g billion-context`, start the proxy with `bili`, and open . Full configuration lives at `~/.config/billion-context/billion-context.json` — `{ }` is a valid configuration. Read the [docs](../docs/) for everything else. +One npm package, Node 22+, MIT license. Install with `npm install -g billion-context` (Linux/macOS without nvm/Homebrew Node: `npm config set prefix "$HOME/.local"` first so it updates itself without `sudo`), start the proxy with `bili`, and open . Full configuration lives at `~/.config/billion-context/billion-context.json` — `{ }` is a valid configuration. Read the [docs](../docs/) for everything else. > Note: this is a sample post demonstrating the blog format (a markdown subset rendered to static pages by `tools/build-blog.mjs`). The first real story will replace it. diff --git a/website/blog/posts/2026-10-08_meet-bili.zh.md b/website/blog/posts/2026-10-08_meet-bili.zh.md index 88d4d1e99e..d67fddedf7 100644 --- a/website/blog/posts/2026-10-08_meet-bili.zh.md +++ b/website/blog/posts/2026-10-08_meet-bili.zh.md @@ -25,6 +25,6 @@ billion-context 在本地以「仅回环」的代理方式运行在你的编码 ## 它跑在哪里 -一个 npm 包,Node 22+,MIT 协议。`npm install -g billion-context` 安装,`bili` 启动代理,浏览器打开 。完整配置在 `~/.config/billion-context/billion-context.json`——`{ }` 就是合法配置。其余一切见[文档](../docs/)。 +一个 npm 包,Node 22+,MIT 协议。`npm install -g billion-context` 安装(非 nvm/Homebrew Node 的 Linux/macOS 先 `npm config set prefix "$HOME/.local"`,自更新就不需要 `sudo`),`bili` 启动代理,浏览器打开 。完整配置在 `~/.config/billion-context/billion-context.json`——`{ }` 就是合法配置。其余一切见[文档](../docs/)。 > 说明:这是一篇示例文章,用来演示博客格式(markdown 子集,由 `tools/build-blog.mjs` 渲染成静态页)。首篇正式文章会替换它。