.MJS

MJS-bestand

Node.js ES Module File
Stel een vraag
SNEL ANTWOORD

Een .mjs-bestand is JavaScript-broncode die Node.js behandelt als een ECMAScript-module, wat betekent dat het import en export gebruikt in plaats van CommonJS require. De extensie bestaat zodat Node ES-modules kan onderscheiden van oudere CommonJS-bestanden zonder package.json te controleren. Omdat het platte tekst is, kunt u een .mjs-bestand openen en bewerken in elke code-editor zoals Visual Studio Code, Sublime Text of Vim, en u voert het uit met node file.mjs.

Ontwikkelaar: Node.js Foundation / OpenJS Foundation (Ecma International for ECMAScript) Categorie: Ontwikkelaarsbestanden Open standaard MIME: text/javascript
OPENT OP Windows macOS Linux Web
Gerelateerd: .DO · .MD · .HEX · .XSD

Op deze pagina

19k+ extensies geïndexeerd
Laatst beoordeeld op Sep 10, 2026

Niet zeker wat uw bestand is?

Sleep een bestand naar onze identificatietool - we lezen alleen de eerste bytes om het formaat te benoemen.

Identificeer een bestand

Wat is het MJS-bestandsformaat?

Een .mjs-bestand is JavaScript-broncode die Node.js laadt als een ECMAScript-module (ESM). De extensie is een signaal: elk bestand dat eindigt op .mjs wordt behandeld als een ES-module, met gebruik van import- en export-statements, zelfs wanneer de package.json van het project niets vermeldt over het moduletype.

Node.js voegde de extensie toe in versie 8.5.0 (2017), eerst achter de --experimental-modules-vlag, en maakte deze stabiel in versie 12. Het bestaat om twee modulesystemen uit elkaar te houden. Oudere Node-code gebruikt CommonJS met require() en module.exports, terwijl moderne code ESM gebruikt. Een gewoon .js-bestand is standaard CommonJS, dus .mjs biedt een ondubbelzinnige manier om voor modules te kiezen. De bijbehorende .cjs-extensie dwingt CommonJS af in de andere richting.

Code in een .mjs-bestand draait automatisch in „strict mode” en kan top-level await en het import.meta-object gebruiken, die beide niet werken in CommonJS. Bundlers zoals webpack, Rollup en Vite kunnen .mjs zowel lezen als schrijven.

Beveiliging & veiligheid

RISICO: 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.

Formaatdetails

in een notendop
VOLLEDIGE NAAMNode.js ES Module Fileook bekend als Module JavaScript file, ES Module file
ONTWIKKELAARNode.js Foundation / OpenJS Foundation (Ecma International for ECMAScript)sinds 2017 (Node.js v8.5.0)
MIME-TYPEtext/javascript
TYPEPlain-text JavaScript source code
STANDAARDOpen · royaltyvrij
GERELATEERD.do.md.hex.xsd
Deze extensie wordt ook gebruikt door…
  • 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.

Programma's die MJS-bestanden openen

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

Technische details

diepe specificaties
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
Uitgebracht2017 (Node.js v8.5.0)
Laatste versieECMAScript 2015 module system (stabilized in Node.js v12+)
Open standaardJa · royaltyvrij
Specificatienodejs.org

MJS conversies

Community V&A

gevraagd door gebruikers
Stel een korte vraag
Krijg hulp van mensen die met MJS-bestanden werken. Wees specifiek - vermeld uw systeem en softwareversie.
Geen account nodig · antwoorden meestal binnen een dag

Nog geen vragen - wees de eerste om iets te vragen over MJS-bestanden.

Veelgestelde vragen

Wat is een .mjs-bestand?
Het is een JavaScript-bronbestand dat Node.js laadt als een ECMAScript-module, waarbij import en export worden gebruikt in plaats van CommonJS require. De .mjs-extensie vertelt Node om het bestand als een ES-module te behandelen, ongeacht de package.json-instellingen.
Hoe open ik een .mjs-bestand?
Open het in een code-editor zoals Visual Studio Code, Sublime Text of Vim, aangezien het platte tekst is. Om het uit te voeren, gebruikt u het commando „node file.mjs” met Node.js geïnstalleerd.
Wat is het verschil tussen .mjs en .js?
Een .mjs-bestand is altijd een ES-module. Een .js-bestand is in Node.js standaard CommonJS en wordt pas een ES-module wanneer de package.json van het project „type”: „module” bevat. De .mjs-extensie neemt die onduidelijkheid weg.
Wat is het verschil tussen .mjs en .cjs?
De .mjs-extensie dwingt het ES-modulesysteem af (import/export), terwijl .cjs CommonJS afdwingt (require/module.exports). Hiermee kunt u beide modulesystemen in één project combineren.
Kunnen browsers .mjs-bestanden uitvoeren?
Ja. Een browser kan een .mjs-bestand laden via een <script type="module">-tag, maar de webserver moet het serveren met een JavaScript MIME-type zoals text/javascript.
Is .mjs veilig om te openen?
Het openen in een editor is veilig omdat het alleen tekst is. Het uitvoeren ervan voert code uit, dus voer alleen .mjs-bestanden uit van vertrouwde bronnen en controleer eerst de inhoud.

Referenties

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

Blijf ontdekken

door de database

Populaire extensies deze week

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)

Gerelateerde extensies

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

Gratis bestandstools

Een bestandsidentificatie en afbeeldingsconverter in de browser - alles draait op uw eigen apparaat.

Open de gereedschapskist

Blader door bestandsextensies A-Z