Registry / devops / muxml
library2.0.1jsnpmunverified

muxml is a Node.js streaming XML parser and formatter built on sax. It accepts XML strings via a Transform stream and emits individual XML elements as chunks. It supports minification, beautification, and stripping of comments, CDATA, instructions, doctype declarations, and attributes, plus tag filtering. The package is available in ES6 and ES5/UMD formats for Node.js >=4 and browser. Current stable version 2.0.1 requires Node.js >=8. It is maintained, but the last release was in 2019.

npm install muxml
INSTALL
IMPORT
SIG · MUXML
M
muxml
devopsjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

muxml (default)
const muxml = require('muxml');
import muxml from 'muxml'; // Wrong: muxml does not export ESM; use CJS require.
Package uses CommonJS; ESM import may fail in Node unless using a bundler.
muxml (default)
import muxml from 'muxml'; // Only works with bundlers or Node ESM with --experimental-modules (older Node)
const { muxml } = require('muxml'); // Wrong: muxml is exported as a function, not named export.
If using ESM, ensure a default import wrapper or use require. No named exports.
muxml (browser global)
<script src="node_modules/muxml/dist/muxml.js"></script>
const muxml = window.muxml; // Wrong: global variable is 'muxml' already.
In browser, muxml attaches to window.muxml as a function. No import needed.

Reads an XML file, streams it through muxml with pretty disabled, and logs each element chunk as a string.

const fs = require('fs'); const muxml = require('muxml'); fs.createReadStream('example.xml') .pipe(muxml({ pretty: false })) .on('data', (chunk) => { console.log(chunk.toString()); });
Debug
Known issues
gotchaThe 'trim' option of sax cannot be set to false; muxml always trims whitespace.
fix
Do not set saxOptions.trim to false; it will be ignored.
affects: >=0.0.0
gotchamuxml requires Node.js >=8; older versions are not supported due to ES6 syntax.
fix
Upgrade Node.js to >=8 or use an older version of muxml (1.0.1 supports Node >=4).
affects: <=1.0.1
breakingIn version 2.0.0, the package switched from ES5 to ES6/UMD, dropping support for Node <4.
fix
Use muxml@1.0.1 if targeting Node <4.
affects: >=2.0.0
gotchaWhen using browser globally, the script exposes muxml as a function; do not use module imports in script tags.
fix
Use <script> tag and call window.muxml(options).
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'muxml'
Package not installed or incorrect import path.
fix
Run 'npm install muxml' and ensure require('muxml') is used; avoid subpath imports.
TypeError: muxml is not a function
Using named import instead of default import in CJS or ESM context.
fix
Use 'const muxml = require("muxml")' (CJS) or 'import muxml from "muxml"' (ESM with bundler).
SyntaxError: Unexpected token import
Attempting to use ES module import in Node <14 without proper .mjs or type:module.
fix
Use CommonJS require() or set type:module in package.json and use a suitable Node version.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
saxrequiredCore XML parsing; muxml uses sax under the hood.
Agent activity
4 hits · last 30 days
node
4
Resources
packagemuxml
muxml — npm install muxml · libregistry