nodejs

Installation
SKILL.md

Node.js Conventions

Module System

  • Prefer ESM (import/export) — set "type": "module" in package.json
  • In ESM, use import.meta.url for the module URL. For local directory paths, import.meta.dirname is available on file: modules since Node v20.11.0 / v21.2.0; on older supported versions, derive the path with fileURLToPath(import.meta.url) and path.dirname(). The dirname version requirement does not apply to import.meta.url. See Node ESM documentation.
  • For CJS interop, use createRequire(import.meta.url) when importing CJS-only packages
  • Follow project convention — if the project uses CJS, stay consistent

Async Patterns

  • async/await over callbacks — use promise-based APIs (fs/promises, timers/promises)
  • Handle rejections at the responsible boundary — let awaited failures propagate to the existing caller or framework error handler. Catch locally for recovery, cleanup, or useful context, not just to rethrow. Detached promises need an explicit error handler.
  • Promise.all for bounded concurrent work — parallelize independent operations within connection, rate, memory, and file-handle limits. For large or unbounded collections, use the project's bounded worker/batching pattern; do not launch every operation at once
  • Promise.allSettled when all results are needed regardless of individual failures
  • Don't mix async paradigms — don't mix callbacks with promises/async-await in the same flow. Using .catch() for inline error transformation with await is fine
  • Convert callback APIs — use util.promisify to wrap callback-only packages into promises

Error Handling

Installs
13
Repository
noih/dev-skills
First Seen
Apr 30, 2026