.MJS

MJS ファイル

Node.js ES Module File
質問する
クイック回答

An .mjs file is JavaScript source code that Node.js treats as an ECMAScript module, meaning it uses import and export instead of CommonJS require. The extension exists so Node can tell ES modules apart from older CommonJS files without checking package.json. Because it is plain text, you can open and edit an .mjs file in any code editor such as Visual Studio Code, Sublime Text, or Vim, and you run it with node file.mjs.

開発元: Node.js Foundation / OpenJS Foundation (Ecma International for ECMAScript) カテゴリ: 開発用ファイル オープンスタンダード MIME: text/javascript
対応OS Windows macOS Linux Web
関連: .DO · .MD · .HEX · .XSD

このページの内容

19k+ 個の拡張子を索引済み
最終確認日:Sep 10, 2026

ファイルの種類がわかりませんか?

ファイルを識別ツールにドロップしてください。最初の数バイトを読み取って形式を特定します。

ファイルを識別する

MJS ファイル形式とは?

An .mjs file is JavaScript source code that Node.js loads as an ECMAScript module (ESM). The extension is a signal: any file ending in .mjs is treated as an ES module, using import and export statements, even when the project's package.json says nothing about module type.

Node.js added the extension in version 8.5.0 (2017), first behind the --experimental-modules flag, and made it stable in version 12. It exists to keep two module systems apart. Older Node code uses CommonJS with require() and module.exports, while modern code uses ESM. A plain .js file is CommonJS by default, so .mjs gives an unambiguous way to opt into modules. The matching .cjs extension forces CommonJS in the other direction.

Code in an .mjs file runs in strict mode automatically and can use top-level await and the import.meta object, neither of which works in CommonJS. Bundlers such as webpack, Rollup and Vite both read and write .mjs.

セキュリティと安全性

リスク: MEDIUM

An .mjs file is executable JavaScript. Running one with node executes whatever code it contains, so an untrusted .mjs file can perform harmful actions such as reading files or making network requests. Opening it in a text editor is safe; only run .mjs files from sources you trust, and review the code first.

形式の詳細

概要
正式名称Node.js ES Module File別名 Module JavaScript file, ES Module file
開発元Node.js Foundation / OpenJS Foundation (Ecma International for ECMAScript)登場時期 2017 (Node.js v8.5.0)
MIME タイプtext/javascript
タイプPlain-text JavaScript source code
標準規格オープン・ロイヤリティフリー
この拡張子は以下でも使用されています…
  • Generic minified JavaScript module - Some build tools emit .mjs to mark a bundled or minified ES module output rather than a hand-written source file.

MJS ファイルを開くプログラム

Windows5 apps
Sublime Text 有料 Open the file for fast editing; JavaScript syntax highlighting applies to .mjs.
Notepad オープンソース Open the .mjs file to view and edit the raw source with lightweight syntax highlighting.
Visual Studio Code 無料 Open the .mjs file to edit it with ESM-aware syntax highlighting, IntelliSense and an integrated terminal for running node.
Node.js runtime オープンソース Execute the module from a command prompt with 'node file.mjs'; the runtime loads it as an ES module.
WebStorm 有料 Open the containing project to get full ESM refactoring, module resolution and debugging.
macOS5 apps
Sublime Text 有料 Open the .mjs file for quick editing with JavaScript highlighting.
Vim オープンソース Edit the file in the terminal with 'vim file.mjs'.
Visual Studio Code 無料 Open the file to edit with ESM IntelliSense and run it from the built-in terminal.
Node.js runtime オープンソース Run 'node file.mjs' in Terminal to execute the module.
WebStorm 有料 Open the project for module-aware editing, debugging and refactoring of .mjs files.
Linux4 apps
GNU Emacs オープンソース Open the .mjs file with js-mode for editing.
Visual Studio Code 無料 Open the file for ESM-aware editing and run it from the integrated terminal.
Node.js runtime オープンソース Execute 'node file.mjs' from a shell to run the module.
Vim / Neovim オープンソース Edit the file in the terminal with JavaScript syntax support.
Web2 apps
Modern web browsers 無料 Load an .mjs file with <script type="module" src="app.mjs"> when the server sends a JavaScript MIME type.
StackBlitz フリーミアム Open or create .mjs modules in an in-browser Node.js environment and run them instantly.

技術的詳細

詳細仕様
EncodingUTF-8 plain text
Byte orderNot applicable (text file, no byte-order dependence; BOM optional but discouraged)
ContainerNone; raw JavaScript source
Typical sizeA few hundred bytes to tens of kilobytes per module
StructureHuman-readable JavaScript source using the ECMAScript module system. Uses static import and export statements, supports top-level await and import.meta, and runs in strict mode by default. Each .mjs file is a module with its own top-level scope; variables are not shared globally.
IntegrityNone built in; integrity is handled externally (npm package hashes, Subresource Integrity on the web, git).
PlatformsWindows, macOS, Linux, BSD, any OS running Node.js or a modern browser
NotesNode.js treats any .mjs file as an ES module regardless of the package.json "type" field, which is the main reason the extension exists. The counterpart .cjs forces CommonJS. Browsers can also load .mjs via <script type="module"> provided the server sends a JavaScript MIME type. Bundlers such as webpack, Rollup, esbuild and Vite read and emit .mjs.
Runs InNode.js runtime and modern web browsers (via script type=module)
Strict ModeAlways enabled; ES modules run in strict mode automatically
リリース日2017 (Node.js v8.5.0)
最新バージョンECMAScript 2015 module system (stabilized in Node.js v12+)
オープンスタンダードはい · ロイヤリティフリー
仕様書nodejs.org

MJS の変換

コミュニティ Q&A

ユーザーからの質問
質問する
MJS ファイルを扱うユーザーからヘルプを得られます。OSやソフトウェアのバージョンなど、具体的に記載してください。
アカウント不要 ・ 通常1日以内に回答されます

まだ質問はありません。MJS ファイルについて最初の質問をしてみましょう。

よくある質問

What is a .mjs file?
It is a JavaScript source file that Node.js loads as an ECMAScript module, using import and export instead of CommonJS require. The .mjs extension tells Node to treat the file as an ES module regardless of the package.json settings.
How do I open a .mjs file?
Open it in any code editor such as Visual Studio Code, Sublime Text or Vim, since it is plain text. To run it, use the command 'node file.mjs' with Node.js installed.
What is the difference between .mjs and .js?
A .mjs file is always an ES module. A .js file is CommonJS by default in Node.js, and only becomes an ES module when the project's package.json has "type": "module". The .mjs extension removes that ambiguity.
What is the difference between .mjs and .cjs?
The .mjs extension forces the ES module system (import/export), while .cjs forces CommonJS (require/module.exports). They let you mix both module systems in one project.
Can browsers run .mjs files?
Yes. A browser can load an .mjs file through a <script type="module"> tag, but the web server must serve it with a JavaScript MIME type such as text/javascript.
Is .mjs safe to open?
Opening it in an editor is safe because it is just text. Running it executes code, so only run .mjs files from trusted sources and review the contents first.

参考文献

1MDN Web Docs - JavaScript modulesdeveloper.mozilla.org
2Node.js Documentation - Modules: ECMAScript modulesnodejs.org

さらに探索

データベース全体から

今週のトップ拡張子

1.AQQAQQ Instant Messenger File
2.BINCD/DVD Disc Image (BIN/CUE)
3.PARTPartial Download File
4.MDMarkdown Document
5.RPMSGRestricted Permission Message
6.CRDOWNLOADChrome Partial Download File
7.NOMEDIAAndroid No-Media Marker File
8.PRDXSoftMaker Presentations Document
9.PRO6XProPresenter 6 Bundle File
10.SWFSmall Web Format (Shockwave Flash)

関連する拡張子

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

無料ファイルツール

ブラウザで動作するファイル識別および画像変換ツール。すべてお使いのデバイス上で実行されます。

ツールボックスを開く

ファイル拡張子を A-Z で閲覧