⚖️ES vs CommonJS
(Node.js)
ES modules can
import
ES or CommonJS module exports.CommonJS modules can only
require
CommonJS module exports.
module path name
file name extension
execution order
require
(expression) - runs inline, after the code above it.import
(statement) - runs before the rest of the script. (note: import expressions can be dynamic.)
Last updated