skills/npm-library-setup/SKILL.md
Comprehensive guidance on setting up npm libraries with package.json, with a preference for ES Modules (ESM). Use when setting up npm packages, configuring ESM, TypeScript packages, or React component libraries.
npx skillsauth add huozhi/npm-skills npm-library-setupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides comprehensive guidance on setting up an npm library with package.json, with a preference for ES Modules (ESM).
This skill helps you create npm packages that:
"type": "module"exports field (no deprecated module field)Use when:
Categories covered:
Initialize your package:
npm init -y
Configure for ESM by adding "type": "module" to package.json
Install build and test tools:
npm install -D bunchee vitest
Create your source files in src/ and run npm run build
{
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"scripts": {
"build": "bunchee",
"test": "vitest",
"test:run": "vitest run"
},
"engines": {
"node": ">=20"
}
}
Note: Use the oldest currently-maintained LTS version (check Node.js Release Schedule).
"type": "module" for pure ESM packagesexports field instead of deprecated module field.js extensions in imports (even in TypeScript)Install TypeScript and configure:
npm install -D typescript @types/node
Create tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "NodeNext",
"declaration": true,
"strict": true
}
}
Bunchee automatically compiles TypeScript and generates .d.ts files.
Install React as dev dependency:
npm install -D react @types/react
Configure peerDependencies:
{
"peerDependencies": {
"react": "*"
}
}
exports field (no deprecated module field).js)// Named exports
export function greet(name) {
return "Hello, " + name + "!";
}
// Default export
export default class MyLibrary {}
// Import
import { greet } from './module.js';
import MyLibrary from './MyLibrary.js';
Important: Always use .js extension in imports, even in TypeScript files.
my-package/
├── package.json
├── src/
│ ├── index.js # or index.ts
│ └── helpers.js
├── dist/ # Build output
└── README.md
See references/ directory for detailed guides:
See examples/ directory for complete working examples:
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.
development
End-to-end Parallels smoke, upgrade, and rerun workflow for OpenClaw across macOS, Windows, and Linux guests. Use when Codex needs to run, rerun, debug, or interpret VM-based install, onboarding, gateway smoke tests, latest-release-to-main upgrade checks, fresh snapshot retests, or optional Discord roundtrip verification under Parallels.