Skip to content

Conversation

@kimdoyoung0319
Copy link

Environment

Node.js 24.3.0

Problem

With the ES Module import syntax, the library does not properly work with the following error:

[ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '.../node_modules/@origranot/ts-logger/lib/esm/enums' is not supported resolving ES modules imported from .../node_modules/@origranot/ts-logger/lib/esm/index.mjs

This originates from the module import syntax used to import submodules throughout the library. More specifically, imports in the form of

import { Foo } from "./bar"

should be changed to

import { Foo } from "./bar/index.js"

Fix

This problem is fixed by changing the directory imports to proper equivalent file imports. Also, this path adds post-build hook (scripts/postbuild-cjs and scripts/postbuild-esm) that adds package.json for both CommonJS and ES Module libraries so that Node.js can know which import syntax is used.

@kimdoyoung0319 kimdoyoung0319 changed the title Fixed a "Directory import not supported" error. fix: "Directory import not supported" error. Sep 19, 2025
@kimdoyoung0319 kimdoyoung0319 changed the title fix: "Directory import not supported" error. fix: "Directory import not supported" error Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants