プログラミング

node-notifierを使いnode.jsでデスクトップ通知を行うには

デスクトップ通知のためのnode.jsライブラリ、node-notifierのガイドです。
クロスプラットフォームであり、Windows 8/10、macOS、Linuxなどで動作します。

以下はGithubです。

mikaelbr/node-notifier: A Node.js module for sending notifications on native Mac, Windows and Linux (or Growl as fallback)

以下はサンプルコードです。
以下ファイルをnode-notifier_dev.jsなどとして保存します。

const notifier = require('node-notifier');

notifier.notify({
  title: 'My notification',
  message: 'Hello, there!',
  sound: true,
  wait: true
});

実行するためには、node.jsをインストールします。

# node.js [nvm-sh/nvm](https://github.com/nvm-sh/nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
bash
nvm install 13
node -v

node.jsプログラムを実行します。

node node-notifier_dev.js

https://yuis.xsrv.jp/images/ss/ShareX_ScreenShot_cb59d7c3-bca1-4eae-ac2f-09f9bfca6fa2.png

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です