esm

Convert JavaScript and TypeScript projects to ECMAScript Modules with import/export syntax.

3|1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/jon23d/skillz --skill esm-jon23d
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: esm
Source: https://github.com/jon23d/skillz/tree/main/skills/esm
Command: npx skills add https://github.com/jon23d/skillz --skill esm-jon23d

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill ensures that all JavaScript and TypeScript code uses modern ECMAScript Modules (ESM) instead of the older CommonJS module system, promoting better code organization and compatibility.

Core Features & Use Cases

  • Enforces ESM Syntax: Replaces require() and module.exports with import and export.
  • Correct Configuration: Ensures package.json has "type": "module" and tsconfig.json uses "NodeNext" module settings.
  • Path Resolution: Provides the correct pattern for __dirname and __filename in ESM.
  • Use Case: When refactoring a Node.js project from CommonJS to ESM, this Skill guides the conversion of all module syntax and configurations.

Quick Start

Ensure all new JavaScript files use 'import' and 'export' syntax and include the '.js' extension for local imports.

Frequently Asked Questions about esm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a Node.js project from CommonJS to ESM?

Converting a Node.js project to ESM requires replacing require() and module.exports with import/export syntax, adding "type": "module" to package.json, and setting "NodeNext" in tsconfig.json.

Why does __dirname not work with ECMAScript Modules in Node.js?

__dirname does not work with ECMAScript Modules in Node.js because ESM handles path resolution differently, requiring the import.meta.url pattern to resolve directory and filename paths.

What is the correct tsconfig.json setting for TypeScript ESM projects?

The correct tsconfig.json setting for TypeScript ESM projects is the "NodeNext" module option, ensuring TypeScript aligns with Node.js ECMAScript Modules path resolution and syntax.

Do I need to include file extensions for local imports in ESM?

Yes, you need to include the .js extension for local imports in ESM, as ECMAScript Modules in Node.js requires explicit file extensions to properly resolve local module paths.

When should I use ECMAScript Modules instead of CommonJS?

Use ECMAScript Modules instead of CommonJS for modern JavaScript and TypeScript projects to ensure better code organization and compatibility, enforcing standardized import/export syntax across Node.js environments.