This article is about cases where node-notifier doesn’t work and notifications are not received. node-notifier is a cross-platform notification library that runs on node.js, but there are cases where it doesn’t work in certain environments.
Here is sample code:
..
const notifier = require('node-notifier');
..
notifier.notify({
title: program.title,
message: program.message,
sound: true,
wait: true
});
..
Normally this code works, but for example, it may not work in specific environments like WSL (Windows Subsystem for Linux).
In my case, it worked with “node file.js”, but when I uploaded the package to npm and tested the package installation with “npm install —global” and ran the command, the notification didn’t work.
In this case, the problem was solved by installing the package containing node-notifier not from WSL, but from npm of Node.js installed on Windows via Powershell and choco.