升级 dsh 的时候提示 node 版本太老了:
-> % sudo npm install -g @deepseek-ai/dsh@latest
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@deepseek-ai/dsh@0.2.2-rc.1',
npm WARN EBADENGINE required: { node: '>=24.9.0' },
npm WARN EBADENGINE current: { node: 'v22.22.1', npm: '9.2.0' }
npm WARN EBADENGINE }
npm WARN deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
changed 659 packages in 4m
74 packages are looking for funding
run `npm fund` for details
听说现在有一个 Rust 编写的 Node 版本管理工具,比 nvm(Shell 编写)启动更快、更轻量,而且还跨平台。
试了一下,没有遇到任何问题,感觉是挺流畅的。
# 安装
curl -fsSL https://fnm.vercel.app/install | bash
安装之后,自动在我的 Shell 初始化文件(.zshrc)中注入了以下内容:
# fnm
FNM_PATH="/home/catroll/.local/share/fnm"
if [ -d "$FNM_PATH" ]; then
export PATH="$FNM_PATH:$PATH"
eval "$(fnm env --shell zsh)"
fi
AI 说,需要加上 --use-on-cd 参数,进入目录的时候会自动根据 .node-version 或 .nvmrc 来切换版本。
我当然听劝,加上了。
# 安装最新 LTS 版本
-> % fnm use lts-latest
Can't find an installed Node version matching lts-latest.
Do you want to install it? answer [y/N]: y
Installing Node v26.13.1 (x64)
00:00:03 ██████████████████████████████ 32.51 MiB/32.51 MiB (10.02 MiB/s, 0s)
Using Node for alias lts-latest
# 使用最新 LTS 版本作为默认版本
-> % fnm default lts-latest
-> % fnm list
* v26.13.1 lts-latest, default
* system
fnm 只管理当前用户的 Node.js 环境,没有修改系统级 Node.js。当前用户使用 Node.js 26.13.1,而 sudo 提权后仍然使用系统自带的 Node.js 22.22.1。
因此,不能用 sudo 安装,只好移除原来的全局安装,改成用户环境安装:
# 全局环境卸载
-> % sudo npm uninstall -g @deepseek-ai/dsh
# 用户环境安装
-> % npm install -g @deepseek-ai/dsh@0.2.2-rc.3
added 28 packages, removed 11 packages, and changed 643 packages in 19s
npm warn install-scripts 5 packages have install scripts not yet covered by allowScripts:
npm warn install-scripts @deepseek-ai/dsh-subprocess-local@0.2.2-rc.3 (postinstall: node scripts/ensure-spawn-helper.mjs)
npm warn install-scripts koffi@3.1.1 (install: node ./cnoke.cjs -P . -D src/koffi --prebuild --release)
npm warn install-scripts node-pty@1.2.0-beta.15 (install: node scripts/prebuild.js || node-gyp rebuild; postinstall: node scripts/post-install.js)
npm warn install-scripts @google/genai@2.21.0 (preinstall: echo 'preinstall: no-op')
npm warn install-scripts protobufjs@7.6.6 (postinstall: node scripts/postinstall)
npm warn install-scripts
npm warn install-scripts Run `npm install -g --allow-scripts=@deepseek-ai/dsh-subprocess-local,koffi,node-pty,@google/genai,protobufjs` to allow these scripts once, or `npm config set allow-scripts=@deepseek-ai/dsh-subprocess-local,koffi,node-pty,@google/genai,protobufjs --location=user` to allow them for all global installs.
# 撞上 npm 11 的 allowScripts 安全机制:npm 检测到依赖包声明了安装脚本,但这些脚本尚未获得执行授权,因此没有自动执行
# 针对本次安装进行授权
npm install -g --allow-scripts=@deepseek-ai/dsh-subprocess-local,koffi,node-pty,@google/genai,protobufjs
# 针对以后的每次安装进行授权
npm config set allow-scripts=@deepseek-ai/dsh-subprocess-local,koffi,node-pty,@google/genai,protobufjs --location=user
# 然后重新安装:
npm install -g @deepseek-ai/dsh@0.2.2-rc.3
原来生成的 Service 文件也需要适当调整:
-> % cat /home/catroll/.config/systemd/user/dsh-web.service
[Unit]
Description=DeepSeek Harness Web
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=%h
Environment=DSH_HOME=%h/.dsh
# ExecStart=/usr/local/bin/dsh web --no-open --host 192.168.1.38
ExecStart=/home/catroll/.local/share/fnm/node-versions/v26.13.1/installation/bin/dsh web --no-open --host 192.168.1.38
Restart=always
RestartSec=5
[Install]
WantedBy=default.target
systemctl --user daemon-reload
systemctl --user restart dsh-web
systemctl --user status dsh-web