Registry / devops / fmtjs
library5.9.0jsnpmunverified

fmtjs is a JavaScript code formatter for Node.js and the browser, currently at version 5.9.0. It provides opinionated formatting with a focus on speed and minimal configuration, supporting ES modules and CommonJS. The library uses a stable parse-and-print approach with built-in style presets and plugin support for custom rules. Release cadence is monthly with active maintenance. Compared to Prettier, fmtjs offers lighter bundle size and faster formatting for large files, but lacks ecosystem plugins.

npm install fmtjs
INSTALL
IMPORT
SIG · FMTJS
F
fmtjs
devopsjavascriptv5.9.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.

format
import { format } from 'fmtjs'
const { format } = require('fmtjs')
ESM-only since v5.0; use dynamic import for CJS environments.
resolveConfig
import { resolveConfig } from 'fmtjs'
import resolveConfig from 'fmtjs'
Named export, not default. See CHANGELOG for v5 breaking changes.
FmtError
import { FmtError } from 'fmtjs'
const FmtError = require('fmtjs').FmtError
FmtError is a named export; require with destructuring works in CJS but not recommended.

Demonstrates importing the format function and formatting a simple code snippet with a style option.

import { format } from 'fmtjs'; const code = `const x = 1;`; const formatted = format(code, { style: 'standard' }); console.log(formatted); // Output: const x = 1;
Debug
Known issues
breakingVersion 5.0 removed CommonJS default export; only named ESM exports remain.
fix
Replace require('fmtjs') with dynamic import or migrate to named imports: import { format } from 'fmtjs'.
affects: >=5.0
gotchaThe 'style' option 'standard' may add trailing commas inconsistently across different code structures.
fix
Define precise options like { trailingComma: 'es5' } to avoid inconsistencies.
affects: >=4.0
deprecatedThe function 'formatAll' is deprecated and will be removed in v6.0.
fix
Replace with repeated calls to 'format' with file filter logic.
affects: >=5.5
gotchaFormatting large files (>10MB) may cause high memory usage due to node's string handling; recommended to process in chunks.
fix
Use fs.createReadStream and pipe through a transform that calls format on chunks.
affects: <6.0
Errors
Common errors & fixes
TypeError: fmtjs_1.format is not a function
Using default import when format is a named export.
fix
Change 'import format from 'fmtjs'' to 'import { format } from 'fmtjs''
Error: Cannot find module 'fmtjs'
Package not installed or misconfigured in package.json.
fix
Run 'npm install fmtjs' and ensure the package is listed in dependencies.
SyntaxError: Unexpected token 'export'
Using ESM syntax in a CommonJS module without transpilation.
fix
Either use dynamic import: 'const { format } = await import('fmtjs')' or transpile with Babel/TypeScript.
Upgrade
Version history
5.9.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
packagefmtjs
fmtjs — npm install fmtjs · libregistry