Skip to content
Discussion options

You must be logged in to vote

Here are several steps to follow:

  1. Make sure your package is written in ECMAScript modules (ESM) format. This means that you should use import and export statements instead of require and module.exports statements.
  2. Add a "type": "module" field to your package.json file. This tells Node.js that your package is an ESM package.
  3. Use the .mjs file extension for your ESM files. This is the recommended file extension for ESM files.
    If your package has a main entry point, you can use the "exports" field in your package.json file to specify the ESM entry point.

Then let it go, publish your package to the NPM registry as usual.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kamaalsultan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants