📜package.json
JS ⟩ module ⟩ CommonJS ⟩ package.json
(in Node.js)
ES modules can
import
ES or CommonJS module exports.CommonJS modules can only
require
CommonJS module exports.
in an ES module (.mjs
/ .js
of "type":"module"
):
can only use
import
/export
.can import CommonJS exports.
cannot use
require
.
in an CommonJS module (.cjs
/ .js
of "type":"commonjs"
):
cannot use
require
to load an ES module.
Last updated