Installing node-red on Synology NAS

Hi folks,

I've ended up on this thread a few times while working with my node red installation. I thought I would post some things that helped me.

First of all, this thread is very helpful : https://www.rs-online.com/designspark/installing-node-red-on-a-synology-nas

However, for some reason I have different paths to this guy - perhaps because of the account I was logged in to?

First point is that I received errors during the install process, but it all works fine, so don't assume it's not working..

To get it to run so that the process is persistent, you need to run it using pm2 - and, in my case, I need to use explicit paths as follows:

/volume1/@appstore/Node.js_v8/usr/local/bin/pm2 start /volume1/@appstore/Node.js_v8/usr/local/bin/node-red -- -v

(there is no newline character in the above btw).

To get the process to run automatically on boot is not as straight forward as it should be and the guy in the post above doesn't explain the script. First of all, you need to run the script as the user you installed it with and there is a bug in Synology DSM when you try to run a script as a user which isn't the root - see here: http://www.damirscorner.com/blog/posts/20190301-SchedulingATaskOnASynologyNas.html

The script I use to run on boot is as follows:


#!/bin/bash
export USER=[my username]
export HOME="/var/services/homes/[my username]"
cd $HOME
/volume1/@appstore/Node.js_v8/usr/local/bin/pm2 start /volume1/@appstore/Node.js_v8/usr/local/bin/node-red -- -v

The bug linked to above means that scripts run as non-root users will still have the home directory as /root and the $USER is root. The first three lines take care of this by setting the appropriate environment variables and then changing directory to your home directory.

You need to replace [my username] with your username.

Hope this helps someone.