Language concepts

Node package.json type

Try the free JavaScript compiler

Controls how Node interprets .js files in the package scope. Explicit .mjs and .cjs extensions select ESM and CommonJS independently of this field. Multi-file example: save each listed file separately, then run the entry file with Node.js. See the packaged fixture for the original files.

Formal Syntax & Structure

javascript syntaxjavascript
{"type":"module"}

Working Example

Example Snippetjavascript
// File: package.json{"type":"module","name":"local-pricing","version":"1.0.0","exports":"./price.js"}
// File: price.jsexport const price = n => n * 5;
// File: main.jsimport { price } from "local-pricing";console.log(price(3));
JavaScript Reference