Registry / devops / mo-fmt

mo-fmt

JSON →
library0.13.0jsnpmunverified

A standalone CLI tool for formatting Motoko source files, built on Prettier (v2.7) and the prettier-plugin-motoko plugin. Current stable version is 0.13.0, released by DFINITY. It offers a simple command-line interface for formatting .mo files in-place or checking format compliance. The tool can be installed globally via npm or used via npx; portable executables are also available for environments without Node.js. Compared to using the underlying Prettier plugin directly, mo-fmt provides a streamlined, zero-configuration experience for Motoko developers.

npm install mo-fmt
INSTALL
IMPORT
SIG · MO-FMT
M
mo-fmt
devopsjavascriptv0.13.0
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.

mo-fmt (CLI)
npx mo-fmt **/*.mo
npm run mo-fmt **/*.mo
The package is a CLI tool, not a library; use npx or global install. Common mistake: running via npm script without global install.
No programmatic API
Uses CLI only; no programmatic import.
import { fmt } from 'mo-fmt'
This package is a standalone CLI; there is no programmatic API. Use child_process.exec to invoke it programmatically.
Plugin usage
Used via CLI; no direct plugin import.
const plugin = require('mo-fmt')
The format plugin is provided by prettier-plugin-motoko, not mo-fmt. This package is a wrapper CLI.

Shows global installation and basic usage: formatting .mo files and checking format compliance.

# Install globally npm install -g mo-fmt # Format all .mo files in current directory recursively mo-fmt "**/*.mo" # Check formatting without modifying files mo-fmt -c "**/*.mo"
Debug
Known issues
gotchaGlob patterns may not expand correctly on Windows without quotes
fix
Use quotes around glob patterns: mo-fmt "**/*.mo"
affects: >=0.0.0
gotchamo-fmt expects Prettier v2.7 as a peer dependency; incompatible with Prettier v3
fix
Ensure prettier@^2.7 is installed alongside mo-fmt.
affects: >=0.0.0
gotchamo-fmt is a CLI tool only; no programmatic API available
fix
Use child_process.spawn or exec to invoke mo-fmt from Node.js scripts.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier'
Peer dependency prettier not installed.
fix
Run 'npm install prettier@^2.7' in the same project.
bash: mo-fmt: command not found
mo-fmt not installed globally or not in PATH.
fix
Install globally with 'npm install -g mo-fmt' or use 'npx mo-fmt'.
Upgrade
Version history
0.13.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency required for formatting engine; mo-fmt relies on Prettier's core and the plugin.
Agent activity
2 hits · last 30 days
node
2
Resources
packagemo-fmt
mo-fmt — npm install mo-fmt · libregistry