You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently have an issue with this module in my project since we have upgraded Node.js to the latest stable version.
SyntaxError: The requested module 'lru_map' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'lru_map';
const { LRUMap } = pkg;
The solution seems to be easy enough.
The CommonJS way
Rename the source to lru.mjs and fully support import/export, then transpile to CommonJS code to the dist folder. Then modify the package.json with the `exports" config :
Do not rename the source file, but fully support import/export, then transpile to CommonJS code with the extension .cjs to the dist folder (i.e. ./dist/lru.cjs). The modify the package.json with the a similar exports config :
I currently have an issue with this module in my project since we have upgraded Node.js to the latest stable version.
The solution seems to be easy enough.
The CommonJS way
Rename the source to
lru.mjs
and fully supportimport
/export
, then transpile to CommonJS code to thedist
folder. Then modify thepackage.json
with the `exports" config :The Module way
Do not rename the source file, but fully support
import
/export
, then transpile to CommonJS code with the extension.cjs
to thedist
folder (i.e../dist/lru.cjs
). The modify thepackage.json
with the a similarexports
config :Tests
I tested this solution with both Node.js v12 and v14. It works with
babel-node
as well as without.The text was updated successfully, but these errors were encountered: