What is the “module” package.json field for?

Update: April 2022

The module field is not officially defined by Node.js and support is not planned. Instead, the Node.js community settled on package exports which they believe is more versatile.

For practical reasons JavaScript bundlers will continue to support the module field. The esbuild docs explain when to use module as well as related fields main and browser.

Original Answer

Is "module" an official npm property or is this a convention of some kind?

It’s a proposal, but likely to be supported due to de facto usage.

Is there documentation for this somewhere?

There is, in fact, and it can be found right here and later removed here.

What’s it for?

ES6 Module Interoperability in Node. Additional discussion can be found here and here. And here’s a blog post from Rich Harris talking more about it.

Leave a Comment