question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should main and module field values in package.json be switched?

See original GitHub issue

In my project which employs Babel, Jest tests which passed before I started using your package are now failing with a message indicating that the code from your package is not plain JavaScript. In your package.json, the module field is set to "dist/es5/index.js", which I believe uses CommonJS modules, while main is set to "dist/index.js", which employs standard JavaScript modules. Reading this proposal describing how the module field allows opt-in use of standard JavaScript modules (while still providing access to CommonJS modules through main), I feel that these two field values should be switched. And indeed, when I switch them, my tests pass again.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
NetanelBasalcommented, Oct 6, 2018

Switched to ng-packger. Everything should be standard now. (v5.2.0)

0reactions
jeffmathcommented, Oct 8, 2018

5.2.2 fixes the problem with the prod build. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should main and module field values in package.json be switched ...
In your package.json , the module field is set to "dist/es5/index.js" , which I believe uses CommonJS modules, while main is set to...
Read more >
What is the "module" package.json field for? - Stack Overflow
The main field makes sure that Node users using require will be served the UMD version. The module field is not an official...
Read more >
package.json vs package-lock.json: Major Differences
The package.json and package-lock.json files are crucial for node packages. Let's explore how package-lock.json differs from package.json, ...
Read more >
The Basics of Package.json - NodeSource
The main property​​ json is a direction to the entry point to the module that the package. json is describing. In a Node....
Read more >
How To Use Node.js Modules with npm and package.json
This is the default value for a package. json 's main property, which is the point of entry for npm modules.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found