NOTICE: the alert
package name on npm has been given away. This has been
deprecated for a long time. See below. Don't use alert
from npm if you're
expecting an isomorphic alert package.
NOTICE: deprecated use node-notifier
instead, it's better maintained, has more
options, and is all-around a better package. alert
will not get any new
updates.
Cross-platform, isomorphic alert, for Node and browser (previously alert-node)
IMPORTANT this project was previously called alert-node
. The package name
changed in v4. Huge thanks to @iclanzan for the
package name!
- Uses
window.alert
in the browser. - Uses
kdialog
zenity
,yad
,notify-send
,xmessage
,dialog
, orwhiptail
on Linux and BSD (depending on what's available). - Uses
osascript
/System Events
on Mac. - Uses
cscript
on Windows (ormsg
ifcscript
fails). - Defaults to
console.log
.
npm i alert
import alert from 'alert'
alert('howdy')
If using the API, you can specify a program to use. This can be one of:
- dialog (Linux)
- kdialog (Linux)
- notify-send (Linux)
- whiptail (Linux)
- xmessage (Linux)
- yad (Linux)
- zenity (Linux)
- osascript (Mac)
- cscript (Windows)
- msg (Windows)
- console (
console.log
)
Note that this will override any internal checks to get the correct program, and will blow up if you get it wrong. It's advised to just use the default behavior.
import alert from 'alert'
alert('hey!', 'yad')
alert
also has a cli. npm i -g alert
and run alert 'sup brah'
.
To disable alert for testing purposes or otherwise, you can set an environment variable DISABLE_ALERT=1
.