mikaelbr /node-notifier
A Node.js module for sending notifications on native Mac, Windows and Linux (or Growl as fallback)
★ 5,841⑂ 318👁 62⑃ 151● 317▤ 2
+0
日增长
5,841
stars
318
forks
62
watchers
151
prs
317
issues
2
releases
README
node-notifier [![NPM version][npm-image]][npm-url] [![Install size][size-image]][size-url] [![Build Status][ci-image]][ci-url]
Send native desktop notifications from Node.js on macOS, Windows and Linux.
Uses Notification Center on macOS, Toasts on Windows 8+ (taskbar balloons on older
Windows) and notify-send on Linux, with Growl as a fallback.
Works with Electron.
!macOS Screenshot
!Native Windows Screenshot
Install
shell
npm install node-notifier
Requires Node.js 22.22+, 24.15+ or 26+. The package is ES modules only, but
require('node-notifier') still works through Node's require(esm) support.
TypeScript types are included, so @types/node-notifier is no longer needed
(uninstall it if you have it). Each notifier has its own options type, e.g.
NotificationCenterNotification or NotifySendNotification.
CLI
Need notifications from the terminal or a shell script? Use
node-notifier-cli, no install
needed:
shell
npx node-notifier-cli -t "Hello" -m "My message"
See the node-notifier-cli README
for all options.
Usage
javascript
import notifier from 'node-notifier';
notifier.notify('Message');
notifier.notify(
{
title: 'My notification',
message: 'Hello, there!',
icon: '/absolute/path/to/icon.png', // Not supported on macOS or balloons
sound: true,
actions: ['OK', 'Cancel'] // Waits for the user (macOS, Windows, Linux)
},
(error, response, metadata) = {
// metadata.activationType, and metadata.activationValue for actions and replies
}
);
notifier.on('click', (notifierObject, options, event) = {});
notifier.on('timeout', (notifierObject, options) = {});
The default notifier picks the right notifier for your platform (see the
decision flow). Options that a platform doesn't support are
ignored. To tune options per platform, use a notifier directly:
javascript
import {
NotificationCenter, // macOS
WindowsToaster, // Windows 8+
WindowsBalloon, // Windows . Action buttons
reply: false, // Boolean | String. Adds a text field, a string is used as placeholder
timeout: 10, // Seconds to wait for actions/reply, or false to wait forever
wait: false // Shorthand for timeout: 5
},
(error, response, metadata) = {}
);
- Only notifications with actions or reply wait for the user. Others call the
callback right away and emit no click or timeout events.
- metadata.activationType is contentsClicked, actionClicked, replied,
closed or timeout.
- A waiting notification keeps your process alive. Call notifier.clearAll() to
stop waiting on all notifications from that instance.
- icon is not supported. macOS always shows the icon of the sending app. For a
custom icon, build terminal-notifier with your icon
(make icon ICON=logo.png APP_NAME=my-tool) and point customPath to it.
- macOS asks for notification permission the first time a notification is sent.
See example/macInput.ts for actions and reply.
WindowsToaster (Windows 8+)
Uses SnoreToast.
javascript
import { WindowsToaster } from 'nTop issues
#200Notification on host from a docker container?21 comments · 2017-09-07#223Hold Notifications in Windows 10 Notification Center10 comments · 2018-03-06#136Tmux notifier10 comments · 2016-08-31#359Notifications like Slack (Windows)6 comments · 2021-01-20#387Windows Toast Notification - hero image3 comments · 2021-12-08#314Windows 10 - SnoreToast is added to Start Menu3 comments · 2020-02-13#312Icon is small in windows always2 comments · 2020-02-04#311Non-blocking notifications1 comments · 2020-01-22
Latest release
v12.1.0 v12.1.0 2026-10-31What's Changed feat: rewrites to typescript and ships types by @mikaelbr in https://github.com/mikaelbr/node-notifier/pull/476 Full Changelog: https://github.com/mikaelbr/node-notifier/compare/v12.0.0...v12.1.0