finds.dev

feross/hostile

Simple, programmatic `/etc/hosts` manipulation (in node.js)

View on GitHub

★ 796JavaScriptMITupdated Dec 2024

// the take

A tiny Node.js library (and CLI) for reading and writing /etc/hosts programmatically. Useful for local dev tools, test environments, or anything that needs to redirect domains without touching DNS. Feross wrote it; it does one thing.

Sync and async APIs for the same operations — no forced callback hell when you just want a one-liner. The load/unload file commands are genuinely useful for toggling named sets of overrides (think switching between project environments). Idempotent set/remove: calling set twice doesn't duplicate the entry. Very small surface area — the whole implementation is one file, easy to audit.

No atomic writes — it reads the file, modifies it in memory, writes it back, which is a race condition if two processes touch hosts simultaneously. Doesn't handle multiple hostnames on a single IP line (the common hosts file pattern of '127.0.0.1 foo bar baz'), so it can mangle existing entries. No Windows path customization — you're stuck with the hardcoded path, which breaks in corporate environments with non-standard Windows layouts. Callback-based API with sync fallbacks is dated; no Promise interface unless you wrap it yourself.

We read the README, the directory tree and a key source file in July 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
796
Forks
49
Language
JavaScript
License
MIT
Last commit
23 Dec 2024

// nearby

If hostile isn't quite it.

All repos →