What does "type" in package.json actually do?

The 'type' field in package.json determines whether a project uses CommonJS or ES Modules. It defaults to CommonJS if not specified. Adding 'type': 'module' to package.json makes the project use ES Modules, allowing import statements to work. This affects both .js and .ts files. You can also use specific file extensions to force a style, such as .mjs for ES Modules.

Source →
FeedLens — Signal over noise Last 7 days