To install Node-Red globally or not to

I always install Node-RED locally on my side. My workflow looks somewhat like this:

mkdir myNodeREDProject
cd myNodeREDProject
npm init (to create a package.json file)
npm install --save node-red

I then usually add a start script in the package.json file for quick tests:

{
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node node_modules/node-red/red.js -v -u ."
  }

For persistence I use pm2 to run the local copy. A typical pm2 process file would look like this:

nodered_pm2.yaml

apps:
    - name: myNodeREDapp
      script: ./node_modules/node-red/red.js
      args: ["-v", "-u", "."]

That file lives in the myNodeREDProject folder and I would start it like this:

pm2 start nodered_pm2.yaml

I also like to hardcode the name of the flow file in settings.js as it makes it more portable and is not dependant on the hostname.

5 Likes