Files
market/skills/nodejs-runtime/references/package-managers.md
yi-ge 1a50969b93 feat: 拆分 environment-setup 为 Python/Node.js 运行时双核心 + 父级路由
新增双核心 skill(深度集成 DesireCore Hatch/Volta + HTTP API + Socket.IO):
- python-runtime v1.0.1:Python 运行时管理
  · 四级降级:HTTP API → Hatch CLI 绝对路径 → 系统包管理器 → pyenv
  · references:hatch-desirecore / pyenv-fallback / virtualenv / troubleshooting
  · scripts/probe-python.sh:输出 JSON 快照供 Claude 解析决策
- nodejs-runtime v1.0.1:Node.js 运行时管理
  · 四级降级:HTTP API → Volta CLI → 系统包管理器/NodeSource → nvm/fnm
  · references:volta-desirecore / nvm-fallback / package-managers / troubleshooting
  · scripts/probe-node.sh:输出 JSON 快照(含 volta_tools / package_json_volta 等)

environment-setup → dev-environment-setup v2.0.1(重命名 + 重写为 router):
- 从 1380 行手册瘦身为 ~150 行索引
- 仅负责容器(Docker/Podman)/ WSL2 / 办公依赖速查 / 系统工具
- references/desirecore-runtime.md 沉淀 Hatch/Volta 路径表 + HTTP API 速查 +
  Socket.IO 事件契约,作为两个核心 skill 的共享底座
- references/decision-tree.md 定义四级降级决策树
- scripts/probe.sh + probe.ps1 系统级 JSON 探测

三个 SKILL.md 的 L0 改为场景驱动结构(何时使用 / 何时不要用 / 怎么做),
让 AI 凭名字与 L0 即可判断匹配场景。

注册更新:
- builtin-skills.json:新增 python-runtime / nodejs-runtime / dev-environment-setup
  (原 environment-setup 移除),按字母序,共 21 个 skill
- manifest.json:totalSkills 19→21,lastUpdated 2026-05-02

下游同步:
- docx / pdf / xlsx / pptx 中的环境引用从 environment-setup 拆分为
  python-runtime / nodejs-runtime / dev-environment-setup 三向指引

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 13:30:23 +08:00

3.2 KiB
Raw Blame History

包管理器策略npm / pnpm / yarn

选型建议

场景 推荐
默认Node.js 自带) npm
磁盘高效 / 严格依赖 / monorepo pnpm(推荐)
项目已用 yarn yarn classic / berry
DesireCore 应用内 Volta 管理任何之上

通过 DesireCore Volta 安装

VOLTA=~/.desirecore/runtime/volta/volta
export VOLTA_FEATURE_PNPM=1

"$VOLTA" install pnpm@latest
"$VOLTA" install yarn@latest
"$VOLTA" install npm@10

或 HTTP API

BASE="https://127.0.0.1:$(cat ~/.desirecore/agent-service.port)/api/runtime"
curl -sk -X POST "${BASE}/pkg/pnpm/install" -H "Content-Type: application/json" -d '{"version":"latest"}'

项目级固定版本

package.json#volta首选

{
  "volta": {
    "node": "22.11.0",
    "pnpm": "9.5.0"
  }
}

在装了 Volta 的环境中 cd 进项目即自动切换。

packageManager 字段Corepack 标准)

{
  "packageManager": "pnpm@9.5.0"
}

由 CorepackNode 16.10+ 自带)解析,被 npm/pnpm/yarn 自身识别。可与 Volta 共存。

npm 全局安装

不要用 sudo

错误:

sudo npm install -g pkg     # ❌ 文件 owner 变成 root后续维护麻烦

正确:改 npm 全局目录到用户目录。

mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

npm install -g pptxgenjs docx

或用 Volta自动隔离无权限问题

volta install pptxgenjs   # ❌ Volta 不直接装库;只能装 CLI 工具
# 库依赖应通过项目 package.json 管理

pnpm 配置

# 全局存储位置pnpm 单存储多链接的核心)
pnpm config get store-dir
# 默认 ~/.local/share/pnpm/store/v3

# 改 registry
pnpm config set registry https://registry.npmmirror.com/

# 全局安装路径(独立于 npm
pnpm config get global-bin-dir

yarn 配置

# yarn classic
yarn config set registry https://registry.npmmirror.com/

# yarn berry
yarn config set npmRegistryServer https://registry.npmmirror.com/

镜像 / 代理

中国大陆加速

npm config set registry https://registry.npmmirror.com/
pnpm config set registry https://registry.npmmirror.com/
yarn config set registry https://registry.npmmirror.com/

恢复官方:

npm config set registry https://registry.npmjs.org/

公司代理

npm config set proxy http://proxy:port
npm config set https-proxy http://proxy:port

# 取消
npm config delete proxy
npm config delete https-proxy

私有 registryVerdaccio / Nexus

# 项目级(.npmrc
@scope:registry=https://npm.company.com/
//npm.company.com/:_authToken=${NPM_TOKEN}

卸载与清理

# 全局列表
npm ls -g --depth=0
pnpm list -g --depth=0
yarn global list

# 卸载
npm uninstall -g pkg
pnpm uninstall -g pkg
yarn global remove pkg

# 清缓存
npm cache clean --force
pnpm store prune
yarn cache clean

环境快照

probe-node.sh 输出 volta_tools.{node,pnpm,yarn,npm} 列出所有 Volta 管理的版本,registry / proxy 来自 npm 配置。Skill 解析 JSON 即可判断是否需要切换镜像。