What is the difference between .js and .mjs files?
Node.js's native module system is CommonJs.
It has experimental support for the standard ES6 module system and using a
.mjs file extension is part of one way to trigger that support. (As of Node 13, you can trigger support by setting
"type": "module", in package.json).
In short, it is used by Node.js to distinguish between CommonJS and ES6 module files.
See also: Differences between ES6 module system and CommonJs
- mjs an extension for EcmaScript modules
- An MJS file is a source code file containing an ES Module (ECMAScript Module) for use with a Node.js application.
ES Modules allow web and application developers to organize code into smaller reusable components.
NOTE: Some developers informally refer to MJS files as "Michael Jackson Script" files.