ytiurin/hyphen

Import from .mjs in node 19 is not working

ckir opened this issue · 2 comments

ckir commented

Tried as shown in the docs

import { hyphenate, hyphenateHTML, hyphenateHTMLSync, hyphenateSync } from "hyphen/en";

but I get errors

Uncaught Error Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/home/user/bigtext/node_modules/hyphen/en' is not supported resolving ES modules imported from /home/user/bigtext/src/lib/test.mjs Did you mean to import hyphen/en/index.js? at __node_internal_captureLargerStackTrace (internal/errors:490:5) at NodeError (internal/errors:399:5) at finalizeResolution (internal/modules/esm/resolve:224:17) at moduleResolve (internal/modules/esm/resolve:850:10) at defaultResolve (internal/modules/esm/resolve:1058:11) at nextResolve (internal/modules/esm/loader:163:28) at resolve (internal/modules/esm/loader:835:30) at getModuleJob (internal/modules/esm/loader:416:18) at <anonymous> (internal/modules/esm/module_job:76:40) at link (internal/modules/esm/module_job:75:36) --- await --- at processTicksAndRejections (internal/process/task_queues:95:5) --- await --- at runMainESM (internal/modules/run_main:53:21) at executeUserEntryPoint (internal/modules/run_main:79:5) at <anonymous> (internal/main/run_main_module:23:47)

Hi, did you try import {} from "hyphen/en/index.js"? Node don't suport import of dirs, that example should work in a webpack

ckir commented

Worked as

import { createRequire } from "module";
const require = createRequire(import.meta.url);

const Hyphen = require('hyphen/en')
let h = Hyphen.hyphenateSync("Sync version of `hyphenate`")