node-notifier-cli is a command-line interface (CLI) package that provides a convenient way to send cross-platform desktop notifications. It acts as a wrapper around the `node-notifier` library, enabling users to trigger notifications directly from their terminal or shell scripts without writing JavaScript code. It supports various notification systems including macOS Notification Center (since 10.8), Windows Toast notifications, Growl, and `notify-send` for Linux. Version 2.0.0 is the current stable release, with its last major update occurring approximately five years ago. Its release cadence is closely tied to its underlying `node-notifier` library, which provides the core notification functionality. The package differentiates itself from programmatic notification libraries by offering a simple, unified command-line syntax for sending messages, titles, icons, and even opening URLs on click, focusing solely on CLI usability.
npm install node-notifier-cliVerified import paths — ran on the pinned version, not inferred.
Demonstrates global installation and various ways to send desktop notifications, including titles, messages, sounds, custom icons, opening URLs, and piping input.
Users of `node-notifier-cli@2.0.0` should either manually update their `node-notifier` dependency to a non-vulnerable version (e.g., `8.0.2` or later `8.x.x` if available) within their `node_modules` or ideally, avoid using user-controlled input in notification parameters until an official update to `node-notifier-cli` or a safer fork is available. Always validate and sanitize all inputs.
To continue using the `notify` command from the terminal, install `node-notifier-cli` separately: `npm i -g node-notifier-cli`.
Be aware of this platform limitation. For a more integrated custom icon, consider using a programmatic solution (like `node-notifier` directly within an Electron app) that allows bundling with custom executables, or adjust expectations for macOS CLI notifications.
Avoid using the `--subtitle` option when targeting Windows environments. Structure your message to incorporate subtitle-like information within the main `--message` field.
Ensure the necessary native notification tools are installed on your Linux system (e.g., `sudo apt-get install libnotify-bin` on Ubuntu/Debian). On Windows, ensure Windows Notifications are enabled and not blocked by security policies.
Consult the `node-notifier` documentation for a list of supported sound names on macOS. Test sound functionality on target platforms for consistent behavior. Use `--sound none` to explicitly disable sound.
Install the package globally: `npm i -g node-notifier-cli` or ensure that the local `node_modules/.bin` directory is in your PATH if installed locally.
Install `libnotify-bin`: `sudo apt-get install libnotify-bin`.
Ensure your WSL2 setup is configured for GUI applications, potentially involving an X server, or modify Windows permissions for the `SnoreToast.exe` binary used by `node-notifier`. Refer to `node-notifier`'s documentation on 'Windows and WSL2' for detailed steps.
Be aware that custom `timeout` settings may not always be honored on Windows for transient toast notifications. For longer-lasting notifications, consider using the `actions` or `reply` options which inherently require a user interaction to dismiss, or explore platform-specific sticky notification solutions outside of this CLI.