Comparing version
{ | ||
"name": "load-esm", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "index.js", | ||
@@ -50,2 +50,4 @@ "types": "index.d.ts", | ||
"mixed-module environment", | ||
"ERR_REQUIRE_ESM", | ||
"require() of ES Module", | ||
"ERR_PACKAGE_PATH_NOT_EXPORTED", | ||
@@ -52,0 +54,0 @@ "No \"exports\" main defined in" |
@@ -8,6 +8,5 @@ [](https://github.com/Borewit/load-esm/actions/workflows/nodejs-ci.yml) | ||
This resolves the error: | ||
``` | ||
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in... | ||
``` | ||
This may resolve the following errors: | ||
- `Error [ERR_REQUIRE_ESM]: require() of ES Module` | ||
- `Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in...` | ||
@@ -32,5 +31,2 @@ ## Installation | ||
/** | ||
* Import 'file-type' ES-Module in CommonJS Node.js module | ||
*/ | ||
(async () => { | ||
@@ -90,2 +86,6 @@ const esmModule = await loadEsm('esm-module'); | ||
Since Node version 22.12.0 [require is able to load some ESM](https://joyeecheung.github.io/blog/2024/03/18/require-esm-in-node-js/), | ||
although with [some constraints](https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require). | ||
If that works for you, you may longer need to module. | ||
The utility of [load-esm](https://github.com/Borewit/load-esm) bypasses the TypeScript compiler by executing the `import()` outside the compilation scope. | ||
@@ -92,0 +92,0 @@ By doing so, it maintains the intended behavior of `import()` for loading ESM modules dynamically, |
5929
4.46%