ShellJS reimplements common Unix shell utilities on top of Node.js so scripts can copy, move, grep, and pipe files without spawning a separate Bash environment.
Overview
ShellJS exposes synchronous implementations of familiar shell commands—such as cat, cp, mv, rm, grep, sed, and ls—as a JavaScript API you import into Node projects. It aims to be portable across Windows, Linux, and macOS while keeping shell-like globbing behavior.
Commands return ShellString objects that behave like strings with extra helpers, and most operations run synchronously unless you use exec with an async callback. Configuration via set toggles fatal exits, verbosity, and filename expansion.
The project supports a plugin API for third-party commands, and a related shx utility exposes many operations at the real command line. Installation is through npm, with optional global install for standalone scripting outside application code.
Documentation recommends local require imports rather than polluting the global namespace. Related tools such as execa are suggested when you need asynchronous external processes with different semantics than cmd.
Key features
- Portable Unix-like file commands
- Synchronous command API
- Bash-style glob support
- Plugin API for extensions
- Global shx CLI companion
- exec with safer single-command semantics
Use cases
- Cross-platform Node build scripts
- Replacing Bash in JavaScript tooling
- File manipulation in npm automation