Install Node-Red on Mac OS Problem

I found out that Node-Red can be installed on a Mac so I decided to try it as I found a step-by-step YouTube video about how to install it.

I got it to install per the video, and it was running, but when I got to about the 2:30 minute mark it said to hit Ctrl-C then type "exit" to end the Terminal session.

In Terminal I tried Ctrl+C but noting happened. Likewise, typing "exit" (which I did without the quotes) did nothing. So after bookmarking http://127.0.0.1:1880/ in Chrome I quit the Terminal app. Now if I try to go to http://127.0.0.1:1880/ in Chrome it says:

The site can't be reached. 127.0.0.1 refused to connect.

Does anyone know how I can get back into Node-Red?

Stuart

@erktrek

Probably because the node-red is not running? Go back into the terminal and type "node-red" then try it..

That worked. I tried that Ctrl-C again in the Terminal window but it didn't work. So do I have to run Terminal and start node-red every time I want to use it?

Am I correct that I would have to keep a browser with that page open permanently to use any flow I create in it?

Finally, I saw someplace there were some Hubitat things I would want to bring in also. (I don't know if it is code for Hubitat or flows or what).

So no and no.. :grinning_face_with_smiling_eyes:

  1. You'll have to kick off node-red on startup
  2. Node-RED will continue to work (as long as it is running see #1) even if you are not on the UI.

EDIT: I am showing my MacOS ignorance.. I am not sure but hopefully the installation process set it to start at boot. What happens when you reboot?

You need to create a LaunchAgent script and run it.

Use this to create something similar:

plist
$ cat /Library/launchagents/NodeRedServer.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>Node-RedServer</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/node</string>
        <string>/usr/local/bin/node-red</string>
        <string>-v</string>
    </array>
    <key>StandardOutPath</key>
        <string>/Users/<YOU>/.node-red/node-red.log</string>
    <key>StandardErrorPath</key>
        <string>/Users/<YOU>/.node-red/node-red.log</string>
    <key>EnvironmentVariables</key>
    <dict>
            <key>PATH</key>
            <string>/usr/local/bin/:$PATH</string>
    </dict>
</dict>
</plist>

Replace the two occurrences of "<YOU>" with your ID, which is where the .node-red directory is created... normally.

Then you can use it...

launchctl load /Library/launchagents/NodeRedServer.plist

To start Node-Red.

launchctl unload /Library/launchagents/HubConnectProxy.plist

To stop Node-Red.

3 Likes

@Stu_The_K - I have Nodered on a Mac and as @erktrek said, you have to leave it running in the terminal. To auto-start it, you have to install PM2. See the following link for instructions - Starting Node-RED on boot : Node-RED.

Are you sure you are not doing command+c (instead of control+c)? Before I used the PM2 option, I would just minimize the terminal window and leave it running.

You should probably consider using LaunchCTL also :smiley: and avoid having to install PM2.

3 Likes

Thanks. I'll check out your link now. I tried both Ctrl+C and Cmd+C and neither worked. (I have a Logitech K-750 Mac keyboard that has both keys).

Yeah - I should but PM2 works and it's not my "live" instance. I can't remember now why I went the route of PM2 vs LaunchCTL :man_shrugging:t2:

I copied the LaunchAgent code but have a couple of questions:

  1. Do I replace <YOU> with my name, including the < and > or did I insert my name between the brackets? i.e.
    <string>/Users/<Stuart>/
    or
    <string>/Users/Stuart/

Also, I believe I should store it in:
/Library/LaunchAgents/

But what name should I store the file as?

With your login username as displayed in Terminal. No quotes are necessary.

I store my launchagent scripts under

/Users/my-username/Library/LaunchAgents

Basically, the choice is yours, but something like "node-red.plist" would be fine.

3 Likes

The very first line of the hidden code is the path and name that I am using...

/Library/launchagents/NodeRedServer.plist

you should use the same directory and the name can be the same as I use.. why not ? :smiley: but of course the best reason not to is because you're you. :smiley:

and:
<string>/Users/Stuart/.node-red/node-red.log
is correct, assuming you did a generic/standard install of Node-Red. Beyond the obscure format of a plist, the bulk of what's in it is familiar directory path details. You can look in the node red directory and see if you have a log file in use. Just copy that directory path and log file name into the plist. It's the format and spelling of a plist that I'm passing to you. :smiley:

1 Like

Thanks. Have some repair guys here so I'll try it in a bit. BTW, how did you type the echelons without the quotes showing?

You can escape them using a backslash, for eg.
> (was actually "\>")

2 Likes

if you mark text as pre-formatted (via the </> icon) then you need to do nothing special. But in general, a back slash will escape a special char: \

2 Likes

`backticks like this also work <a><b><c><d>`
backticks like this also work <a><b><c><d>

(I used the \ char for the first line)

1 Like

backticks are how preformatted is marked.

2 Likes