Record npx path for deployment runtime

This commit is contained in:
wuyang6
2026-05-11 17:27:40 +08:00
parent 4964548fd1
commit dba827b9b0
3 changed files with 12 additions and 4 deletions
+5 -1
View File
@@ -594,9 +594,13 @@ CLAW_BACKEND_PORT
CLAW_FRONTEND_HOST CLAW_FRONTEND_HOST
CLAW_FRONTEND_PORT CLAW_FRONTEND_PORT
CLAW_API_URL CLAW_API_URL
CLAW_NPM_BIN
CLAW_NPX_BIN
CLAW_NODE_BIN
CLAW_NODE_BIN_DIR
``` ```
该文件包含敏感信息,只保存在部署机器本地,权限设置为 `600`,并已被 `.gitignore` 忽略。 其中 Node.js 相关路径会在部署时自动记录,供 systemd 后端/前端服务以及飞书 MCP 等 Node 生态能力使用。该文件包含敏感信息,只保存在部署机器本地,权限设置为 `600`,并已被 `.gitignore` 忽略。
### 日常更新 ### 日常更新
+6 -3
View File
@@ -264,17 +264,19 @@ build_frontend() {
} }
remember_node_runtime() { remember_node_runtime() {
local npm_bin node_bin node_bin_dir tmp_file local npm_bin npx_bin node_bin node_bin_dir tmp_file
npm_bin="$(resolve_npm_bin)" npm_bin="$(resolve_npm_bin)"
node_bin_dir="$(dirname "${npm_bin}")" node_bin_dir="$(dirname "${npm_bin}")"
export PATH="${node_bin_dir}:${PATH}" export PATH="${node_bin_dir}:${PATH}"
node_bin="$(PATH="${node_bin_dir}:${PATH}" command -v node || true)" node_bin="$(PATH="${node_bin_dir}:${PATH}" command -v node || true)"
npx_bin="$(PATH="${node_bin_dir}:${PATH}" command -v npx || true)"
tmp_file="$(mktemp)" tmp_file="$(mktemp)"
grep -v -E '^(# systemd 用户服务不会读取交互式 shell 配置|export CLAW_(NPM_BIN|NODE_BIN|NODE_BIN_DIR)=)' "${ENV_FILE}" >"${tmp_file}" || true grep -v -E '^(# systemd 用户服务不会读取交互式 shell 配置|export CLAW_(NPM_BIN|NPX_BIN|NODE_BIN|NODE_BIN_DIR)=)' "${ENV_FILE}" >"${tmp_file}" || true
cat >>"${tmp_file}" <<EOF cat >>"${tmp_file}" <<EOF
# systemd 用户服务不会读取交互式 shell 配置,这里记录部署时可用的 Node.js/npm 路径。 # systemd 用户服务不会读取交互式 shell 配置,这里记录部署时可用的 Node.js/npm/npx 路径。
export CLAW_NPM_BIN=$(printf "%q" "${npm_bin}") export CLAW_NPM_BIN=$(printf "%q" "${npm_bin}")
export CLAW_NPX_BIN=$(printf "%q" "${npx_bin}")
export CLAW_NODE_BIN=$(printf "%q" "${node_bin}") export CLAW_NODE_BIN=$(printf "%q" "${node_bin}")
export CLAW_NODE_BIN_DIR=$(printf "%q" "${node_bin_dir}") export CLAW_NODE_BIN_DIR=$(printf "%q" "${node_bin_dir}")
EOF EOF
@@ -282,6 +284,7 @@ EOF
rm -f "${tmp_file}" rm -f "${tmp_file}"
log "记录 Node.js 运行路径" log "记录 Node.js 运行路径"
echo "npm=${npm_bin}" echo "npm=${npm_bin}"
echo "npx=${npx_bin:-未检测到}"
echo "node=${node_bin:-未检测到}" echo "node=${node_bin:-未检测到}"
} }
+1
View File
@@ -26,6 +26,7 @@ if [[ -n "${CLAW_NODE_BIN_DIR:-}" ]]; then
export PATH="${CLAW_NODE_BIN_DIR}:${PATH}" export PATH="${CLAW_NODE_BIN_DIR}:${PATH}"
fi fi
export CLAW_NPM_BIN="${CLAW_NPM_BIN:-}" export CLAW_NPM_BIN="${CLAW_NPM_BIN:-}"
export CLAW_NPX_BIN="${CLAW_NPX_BIN:-}"
export CLAW_NODE_BIN="${CLAW_NODE_BIN:-}" export CLAW_NODE_BIN="${CLAW_NODE_BIN:-}"
export CLAW_NODE_BIN_DIR="${CLAW_NODE_BIN_DIR:-}" export CLAW_NODE_BIN_DIR="${CLAW_NODE_BIN_DIR:-}"