Skip to content

Cannot use as an esm module in nodejs project #512

@StevenDepa

Description

@StevenDepa

If I create an esm project (es. I put "type": "module" in the package.json), then I do:

node index.js

with an index.js that is simply:

import flexsearch from "flexsearch";

const d = new flexsearch.Document({});

this results in the error:

(node:10112) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

I think that the compiled esm file is not correctly recognised as an esm module, I think the solution would be to simply have the file flexsearch\dist\flexsearch.bundle.module.min.js have the .mjs extension (I tried and it works).
This should work without messing up with the other type of imports.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions