prettier_d_slim

raw JSON →
1.2.0 verified Sat Apr 25 auth: no javascript

A daemon wrapper for Prettier that dramatically reduces formatting time by running a background server, eliminating Node.js startup and module loading overhead. Current stable version is 1.2.0, with infrequent releases. Compared to alternatives like prettier_d, prettier_d_slim is minimal and stable, with a smaller footprint. It automatically picks a free port, stores credentials in ~/.prettier_d_slim, and supports per-directory Prettier versions via a nanolru cache. Ideal for editor save-time formatting where sub-150ms latency is desired.

error Error: No such file or directory (os error 2) open '~/.prettier_d_slim'
cause The server has not been started yet, or the credentials file was deleted.
fix
Run 'prettier_d_slim start' to start the server and create the file.
error Error: listen EADDRINUSE :::<port>
cause The random port chosen by prettier_d_slim is already in use, or a previous server instance wasn't properly shut down.
fix
Run 'prettier_d_slim stop' to stop any existing server, then retry. If the port is occupied by another process, wait or manually kill the process.
error stdin is not a TTY
cause The command expects stdin input but it was not piped or redirected.
fix
Redirect a file: 'prettier_d_slim --stdin --stdin-filepath file.js < file.js' or use --text.
error prettier_d_slim: command not found
cause The package is not installed globally or not in PATH.
fix
Install globally with 'npm install -g prettier_d_slim' or use npx: 'npx prettier_d_slim ...'
gotcha The first invocation always starts the server and takes ~700ms. Subsequent calls are fast (~130ms).
fix Run a warm-up call (e.g., format a dummy file) before performance-critical workflows.
gotcha The server binds to a random port and stores credentials in ~/.prettier_d_slim. Deleting this file breaks communication until server restart.
fix Do not manually delete ~/.prettier_d_slim while server is running. Use 'prettier_d_slim stop' to cleanly shutdown.
gotcha Per-directory Prettier versions are cached up to 10 entries. If you switch between many projects, older directories may lose their cached instance.
fix The cache is LRU with size 10. To force a fresh instance for a directory, use 'prettier_d_slim restart' or remove the cache by stopping the server.
gotcha When using stdin, the file path must be provided via --stdin-filepath, otherwise Prettier cannot infer the parser.
fix Always use --stdin-filepath with a filename that matches the language (e.g., file.js, file.ts, file.css).
npm install prettier_d_slim
yarn add prettier_d_slim
pnpm add prettier_d_slim

Demonstrates installation, basic stdin formatting, server control commands, and netcat usage for sub-50ms formatting.

// Install globally
$ npm install -g prettier_d_slim

# Format a file via stdin (first time starts server, ~130ms)
$ cat file.js | prettier_d_slim --stdin --stdin-filepath file.js

# Format with text argument
$ prettier_d_slim --stdin-filepath file.js --text 'const foo = {}'

# Control server
$ prettier_d_slim start
$ prettier_d_slim status
$ prettier_d_slim restart
$ prettier_d_slim stop

# Super fast with netcat (<50ms after server running)
$ PORT=$(cat ~/.prettier_d_slim | cut -d" " -f1)
$ TOKEN=$(cat ~/.prettier_d_slim | cut -d" " -f2)
$ echo "$TOKEN $PWD file.js" | nc localhost $PORT