File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { createRequire } from "node:module" ;
2+ import { dirname } from "node:path" ;
3+ import { fileURLToPath } from "node:url" ;
24
35const require = createRequire ( import . meta. url ) ;
6+ // `__dirname` is not defined in ES module scope (package.json sets
7+ // "type": "module"), so referencing it crashes the entry on load with
8+ // ERR_AMBIGUOUS_MODULE_SYNTAX on modern Node. `import.meta.dirname` is
9+ // the ESM equivalent on Node ≥ 20.11; fall back to a fileURLToPath-based
10+ // derivation to honor the declared engines floor (node >=18). Resolving
11+ // the native binding path at load time keeps `npm test` and any ESM
12+ // consumer working on plain `import Arkilian from "arkilian"`.
13+ const __dirname = import . meta. dirname ?? dirname ( fileURLToPath ( import . meta. url ) ) ;
414// Runtime resolution via node-gyp-build: picks the prebuilt .node for this
515// platform/arch from the bundled prebuilds/ dir (offline, no compiler),
616// falling back to the build/Release output of a source build. Lets
You can’t perform that action at this time.
0 commit comments