typescript-node-esm-compiler-runtime

Diagnose and align TypeScript compiler settings with Node.js ESM runtime behavior.

1|1|Updated Apr 8, 2026
One-click install
npx skills add https://github.com/GonkaGate/opencode-setup --skill typescript-node-esm-compiler-runtime-gonkagate
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-node-esm-compiler-runtime
Source: https://github.com/GonkaGate/opencode-setup/tree/main/.agents/skills/typescript-node-esm-compiler-runtime
Command: npx skills add https://github.com/GonkaGate/opencode-setup --skill typescript-node-esm-compiler-runtime-gonkagate

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? TypeScript projects often compile successfully but fail at runtime in Node.js ESM with errors like ERR_MODULE_NOT_FOUND, directory import failures, or "works in tsx but not in node dist". This Skill resolves the mismatch between what TypeScript emits, what Node actually resolves, and what files exist on disk. ## Core Features & Use Cases - Runtime Mode Diagnosis: Determines whether the real execution contract is compiled JS (tsc -> dist -> node), native .ts type stripping, or a runner like tsx/ts-node, and checks each layer for drift. - Config and Specifier Alignment: Guides choices for module, moduleResolution, verbatimModuleSyntax, rewriteRelativeImportExtensions, .js vs .ts relative specifiers, and package.json "type"/"exports"/"imports" versus tsconfig.paths aliases. - Failure Triage: Maps concrete errors such as ERR_MODULE_NOT_FOUND, ERR_UNSUPPORTED_DIR_IMPORT, and "Cannot use import statement outside a module" to their likely mismatch seam and first discriminating check. - Use Case: A service passes tests under tsx but crashes in production with ERR_MODULE_NOT_FOUND after tsc build; the Skill inspects the start command, package.json, effective tsconfig, and emitted dist files to pinpoint the specifier or alias drift and recommend the smallest fix. ## Quick Start Ask the assistant to diagnose why your TypeScript project compiles but fails when run with node dist, and have it inspect your package.json, tsconfig, and emitted import strings.

Frequently Asked Questions about typescript-node-esm-compiler-runtime

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

FAQPage Schema
Why does my TypeScript project compile but fail with ERR_MODULE_NOT_FOUND in Node?

ERR_MODULE_NOT_FOUND usually means an extensionless relative import, an emitted import string pointing to the wrong file or extension, or an alias TypeScript resolves but Node does not. Inspect the exact import string in the emitted file and confirm the target file exists with that extension.

Should I use .js or .ts extensions in relative imports for Node ESM?

Use .js relative specifiers when Node executes emitted JS from dist, since the emitted string must match real files on disk. Use .ts specifiers only when Node itself executes .ts files through native type stripping.

Does Node.js resolve tsconfig paths aliases at runtime?

No, Node does not read tsconfig.json, so tsconfig.paths is compile-time only. For aliases Node must understand, use package.json "imports" with #-prefixed specifiers, or add an explicit runtime resolution layer.

Why does my code work in tsx but fail with node dist?

Runners like tsx are more permissive than production Node, often allowing extensionless imports, aliases, or direct .ts execution. If production runs node dist, validate that exact command and treat runner-only success as drift, not proof.

Can Node.js run TypeScript files directly without compiling?

Modern Node supports native .ts execution via type stripping, but it still requires explicit extensions, ignores tsconfig, and does no type checking. Syntax needing transformation is not automatically safe, so this mode is narrower than compiled JS.

When should I use nodenext versus a frozen Node module mode in tsconfig?

Choose nodenext when tracking current Node behavior is acceptable for your project. Choose a frozen Node mode only when stability against compiler drift matters more than following the newest Node semantics.