Last active
February 14, 2024 01:41
-
-
Save v-kolesnikov/05a7a53f8ff77c0f9a503b5b4a3fd6bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CommonJS | |
ESM | |
AMD | |
ES modules | |
ES6 modules | |
mjs | |
import, export | |
script defer | |
--- | |
Node.js's original module system is CommonJs (which uses require and module.exports). | |
Since Node.js was created, the ECMAScript module system (which uses import and export) has become standard and Node.js has added support for it. | |
Node.js will treat .cjs files as CommonJS modules and .mjs files as ECMAScript modules. It will treat .js files as whatever the default module system for the project is (which is CommonJS unless package.json says "type": "module",). | |
https://nodejs.org/docs/latest/api/esm.html#esm_differences_between_es_modules_and_commonjs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment