{"id":20467,"library":"prettier_d_slim","title":"prettier_d_slim","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/mikew/prettier_d_slim.js","tags":["javascript","prettier","daemon"],"install":[{"cmd":"npm install prettier_d_slim","lang":"bash","label":"npm"},{"cmd":"yarn add prettier_d_slim","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier_d_slim","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency: prettier_d_slim wraps Prettier and falls back to its own bundled version if not found locally.","package":"prettier","optional":true},{"reason":"Library that manages the background server lifecycle (start, stop, communication).","package":"core_d","optional":false},{"reason":"Used internally to cache up to 10 Prettier instances by working directory.","package":"nanolru","optional":false}],"imports":[{"note":"prettier_d_slim is a CLI tool, not a library. It expects input via stdin or --text. File arguments alone may not work as expected.","wrong":"prettier_d_slim file.js","symbol":"default (CLI)","correct":"npx prettier_d_slim --stdin-filepath file.js < file.js"},{"note":"Commands are positional, not flags. Use 'prettier_d_slim start' not '--start'.","wrong":"prettier_d_slim --start","symbol":"start/stop/restart/status commands","correct":"prettier_d_slim start"},{"note":"core_d is a CommonJS library. ESM import may cause issues if your project is not configured for CJS interop. Use require() or a dynamic import.","wrong":"import { core_d } from 'core_d';","symbol":"Programmatic usage (core_d)","correct":"const core_d = require('core_d');"}],"quickstart":{"code":"// Install globally\n$ npm install -g prettier_d_slim\n\n# Format a file via stdin (first time starts server, ~130ms)\n$ cat file.js | prettier_d_slim --stdin --stdin-filepath file.js\n\n# Format with text argument\n$ prettier_d_slim --stdin-filepath file.js --text 'const foo = {}'\n\n# Control server\n$ prettier_d_slim start\n$ prettier_d_slim status\n$ prettier_d_slim restart\n$ prettier_d_slim stop\n\n# Super fast with netcat (<50ms after server running)\n$ PORT=$(cat ~/.prettier_d_slim | cut -d\" \" -f1)\n$ TOKEN=$(cat ~/.prettier_d_slim | cut -d\" \" -f2)\n$ echo \"$TOKEN $PWD file.js\" | nc localhost $PORT","lang":"bash","description":"Demonstrates installation, basic stdin formatting, server control commands, and netcat usage for sub-50ms formatting."},"warnings":[{"fix":"Run a warm-up call (e.g., format a dummy file) before performance-critical workflows.","message":"The first invocation always starts the server and takes ~700ms. Subsequent calls are fast (~130ms).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Do not manually delete ~/.prettier_d_slim while server is running. Use 'prettier_d_slim stop' to cleanly shutdown.","message":"The server binds to a random port and stores credentials in ~/.prettier_d_slim. Deleting this file breaks communication until server restart.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Per-directory Prettier versions are cached up to 10 entries. If you switch between many projects, older directories may lose their cached instance.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use --stdin-filepath with a filename that matches the language (e.g., file.js, file.ts, file.css).","message":"When using stdin, the file path must be provided via --stdin-filepath, otherwise Prettier cannot infer the parser.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'prettier_d_slim start' to start the server and create the file.","cause":"The server has not been started yet, or the credentials file was deleted.","error":"Error: No such file or directory (os error 2) open '~/.prettier_d_slim'"},{"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.","cause":"The random port chosen by prettier_d_slim is already in use, or a previous server instance wasn't properly shut down.","error":"Error: listen EADDRINUSE :::<port>"},{"fix":"Redirect a file: 'prettier_d_slim --stdin --stdin-filepath file.js < file.js' or use --text.","cause":"The command expects stdin input but it was not piped or redirected.","error":"stdin is not a TTY"},{"fix":"Install globally with 'npm install -g prettier_d_slim' or use npx: 'npx prettier_d_slim ...'","cause":"The package is not installed globally or not in PATH.","error":"prettier_d_slim: command not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}