huozhi/npm-skills/npm-library-setup
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install huozhi/npm-skills/npm-library-setupSKILL.md
npm Library Setup with ESM
This skill provides comprehensive guidance on setting up an npm library with package.json, with a preference for ES Modules (ESM).
Overview
This skill helps you create npm packages that:
- Use ES Modules (ESM) with
"type": "module" - Configure modern
exportsfield (no deprecatedmodulefield) - Use bunchee for zero-config bundling
- Use vitest for modern testing
- Support TypeScript and React component libraries
When to Use This Skill
Use when:
- "Set up an npm package"
- "Create a new npm library"
- "Configure package.json for ESM"
- "Set up a TypeScript npm package"
- "Create a React component library"
Categories covered:
- Basic package setup with ESM
- TypeScript package configuration
- React component library setup
- Build configuration with bunchee
- Testing setup with vitest
Quick Start
- Initialize your package:
``bash npm init -y ``
- Configure for ESM by adding
"type": "module"topackage.json
- Install build and test tools:
``bash npm install -D bunchee vitest ``
- Create your source files in
src/and runnpm run build
Essential Configuration
package.json
Note: Use the oldest currently-maintained LTS version (check Node.js Release Schedule).
Key Principles
- ESM-first: Use
"type": "module"for pure ESM packages - Modern exports: Use
exportsfield instead of deprecatedmodulefield - Zero-config bundling: Bunchee handles most configuration automatically
- File extensions: Use explicit
.jsextensions in imports (even in TypeScript) - Kebab-case files: Use kebab-case for file paths
TypeScript Setup
Install TypeScript and configure:
Create tsconfig.json:
Bunchee automatically compiles TypeScript and generates .d.ts files.
React Component Libraries
Install React as dev dependency:
Configure peerDependencies:
Best Practices
- ✅ Use
exportsfield (no deprecatedmodulefield) - ✅ Use explicit file extensions in imports (
.js) - ✅ Use kebab-case for file paths
- ✅ Separate runtime dependencies from dev dependencies
- ✅ Specify Node.js version using oldest maintained LTS
- ✅ Write source in ESM syntax
Common Patterns
ESM Import/Export
Important: Always use .js extension in imports, even in TypeScript files.
File Structure
References
See references/ directory for detailed guides:
- Getting Started
- Package.json Configuration
- ESM Syntax and Patterns
- Building and Testing
- TypeScript Packages
- React Packages
- Best Practices
Examples
See examples/ directory for complete working examples:
- JavaScript ESM package
- TypeScript ESM package
Additional Resources
- Node.js Release Schedule - Check oldest maintained LTS
- Bunchee Documentation - Build tool
- Vitest Documentation - Test runner
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/npm-library-setup/SKILL.md
Popularity
- Repository stars
- 3
- 7-day trend score
- 7
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 22 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/huozhi/npm-skills/npm-library-setup)