{"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,"search_vec":"'/.prettier_d_slim':60 '1.2.0':30 '150ms':82 'altern':36 'automat':52 'background':17 'cach':71 'compar':34 'credenti':58 'current':26 'd':2,39,41 'daemon':5,88 'desir':85 'directori':65 'dramat':10 'editor':74 'elimin':19 'footprint':50 'format':12,78 'free':55 'ideal':72 'infrequ':32 'javascript':86 'latenc':83 'like':37 'load':24 'minim':44 'modul':23 'nanolru':70 'node.js':20 'overhead':25 'per':64 'per-directori':63 'pick':53 'port':56 'prettier':1,8,38,40,66,87 'reduc':11 'releas':33 'run':15 'save':76 'save-tim':75 'server':18 'slim':3,42 'smaller':49 'stabl':27,46 'startup':21 'store':57 'sub':81 'sub-150ms':80 'support':62 'time':13,77 'version':28,67 'via':68 'wrapper':6","created_at":"2026-04-25T11:23:16.113697+00:00","updated_at":"2026-04-25T11:23:16.113697+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"prettier_d_slim","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mikew/prettier_d_slim.js","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/prettier_d_slim","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}