'Is there a way to include an ESM only package via require?
I have a node dependency that is included in version 2 with require. Now with version 3 the library can only be included with import.
Error [ERR_REQUIRE_ESM]: require() of ES Module
But my script uses require.
Is there a way to include an ESM only package via require?
Solution 1:[1]
Yes; I've built the fix-esm library for this purpose. It works basically by transparently converting ESM exports to CJS exports.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sven Slootweg |
