Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

440
Views
What is the "module" package.json field for?

I've seen some npm packages (vue for example) have a module field in their package.json.

But module is not included in the package.json documentation - is this a convention of some kind? Is there documentation for this somewhere?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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 be 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.

over 4 years ago · Santiago Trujillo Report

0

This is used by bundler tools for ESM (ECMAScript Module) detection. The Rollup documentation says it pretty well:

If your package.json file also has a module field, ES6-aware tools like Rollup and webpack 2 will import the ES6 module version directly.

This article on Rollup 1.0 says it another way:

The main field makes sure that Node users using require will be served the UMD version. The module field is not an official npm feature but a common convention among bundlers to designate how to import an ESM version of our library.

Further discussion of pkg.module is on the Rollup Github Wiki and the webpack Docs.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!