返回 Skill 列表
extension
分类: 开发与工程无需 API Key

nodejs-package-json

为Node.js项目的package.json打补丁以实现标准构建自动化。当需要添加/标准化package.json脚本(如TypeScript构建的prebuild/postbuild (rimraf dist + tsc-alias)),调整Next.js的prebuild (rimraf dist .next),或确保现有的package.json pkg配置中包含必需的脚本/资产/目标/outputPath时使用。

person作者: jakexiaohubgithub

Node.js package.json

Goal

Quickly and safely update package.json to include:

  • scripts.prebuild: rimraf dist (or rimraf dist .next for Next.js)
  • scripts.postbuild: tsc-alias
  • If pkg config exists: ensure scripts/assets/targets/outputPath contain required entries

Workflow

  1. Run the patcher (auto-detects Next.js):

    • python3 "${CODEX_HOME:-$HOME/.codex}/skills/nodejs-package-json/scripts/patch_package_json.py" --path package.json
  2. If Next.js auto-detection is wrong, force it:

    • Force Next.js: --nextjs true
    • Force non-Next.js: --nextjs false
  3. If prebuild or postbuild already exist with different values:

    • Re-run with --force to overwrite to the recommended defaults.

Notes

  • This skill edits package.json only; it does not install dependencies. Ensure rimraf and tsc-alias are available (typically as devDependencies).
  • The patcher only edits pkg settings if a top-level pkg object already exists (it does not add one).