Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
main
✓ messageformat-cli is used as a CLI tool; no programmatic import. Run via npx messageformat-cli or global install.
No JavaScript import available; use command line only.
compile output
✓ messageformat-cli generates a .js file that can be imported as a CommonJS module. const msg = require('./messages.js');
✗ import msg from './messages.js'; // Output is CommonJS, not ESM
Output files use module.exports, so require() is required.
CLI usage
✓ npx messageformat-cli input.json output.js
✗ npm run messageformat-cli input.json output.js
Direct CLI invocation, not via npm scripts.
Shows installation, creating a message JSON file, running the CLI to compile, and using the generated module.
npm install -g messageformat-cli messageformat@2
# Create a JSON file with translations
cat > messages.json <<EOF
{
"greeting": "Hello {name}!",
"farewell": "Goodbye {name}!"
}
EOF
# Compile to JavaScript
messageformat-cli messages.json messages.js
# Use in Node.js
const greeting = require('./messages.js').greeting;
console.log(greeting({ name: 'World' })); // Output: Hello World!
messageformat --version
Errors
Common errors & fixes
Error: Cannot find module 'messageformat'
Peer dependency 'messageformat' not installed.
fixnpm install messageformat@2
messageformat-cli: command not found
CLI not installed globally or not in PATH.
fixnpm install -g messageformat-cli messageformat@2
SyntaxError: Unexpected token 'export'
Attempted to import the output file using ESM syntax, but output is CommonJS.
fixUse require() instead of import.
Audit
Dependencies
messageformatrequiredpeer dependency required for compilation