Installation of Node-Red on Ubuntu 18.04 Server

Hey,
I rented a VPS-Server recently and want to try Node-Red on the Server as well, after everything works well already on my Raspberry Pi. But it would also be great to access the data from everywhere.

Unfortunately I do not get Node-Red running on my server. For the installation I followed more or less the tutorial on https://www.markjunghanns.de/index.php/2016/10/19/node-red-installation-ubuntu/
Unfortunately this is only avaliable in german.

Here is what I entered and received in the terminal:
sudo apt-get install npm //no problems

node -v
v8.10.0

npm -v
3.5.2

sudo npm install -g --unsafe-perm node-red

Warnings:
npm WARN ws@7.4.1 requires a peer of bufferutil@^4.0.1 but none was installed.
npm WARN ws@7.4.1 requires a peer of utf-8-validate@^5.0.2 but none was installed.

sudo npm install -g pm2

Warnings:
npm WARN optional Skipping failed optional dependency /pm2/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@2.1.3
npm WARN ws@7.2.5 requires a peer of bufferutil@^4.0.1 but none was installed.
npm WARN ws@7.2.5 requires a peer of utf-8-validate@^5.0.2 but none was installed.

sudo which node-red
/usr/local/bin/node-red

sudo pm2 start /usr/local/bin/node-red
[PM2] Spawning PM2 daemon with pm2_home=/home/ssh_user/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /usr/local/bin/node-red in fork_mode (1 instance)
[PM2] Done.
โ”Œโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ id โ”‚ name โ”‚ mode โ”‚ โ†บ โ”‚ status โ”‚ cpu โ”‚ memory โ”‚
โ”œโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 0 โ”‚ node-red โ”‚ fork โ”‚ 0 โ”‚ online โ”‚ 0% โ”‚ 16.5mb โ”‚

sudo pm2 status
--> same result

sudo pm2 startup

sudo pm2 save

sudo -i

cd /etc/init.d/
ls -a

--> no pm2-init.sh avaliable to change USER=root to USER=hans

Has anyone an idea, what the problem could be? Initially I had node-red already running with Plesk as Admin-Panel installed, but now I changed to KeyHelp and it does not work any more. But I'm not sure, if this is the reason or something else.

Yesterday I already tried another solution:
npm install -g npm-install-peers
npm-install-peers
There doesn't seem to be a package.json here

If I try to reinstall node-red, then the peers seem still not to be installed. I would really appreciate, if someone has some idea, how to install node-red on my server.

Stefan

This is a very old (2016) link!

The installation script in the documentation works well on Ubuntu, I have done it recently.

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Yes - sometimes I wonder if there is a reason we write docs... :cry: https://nodered.org/docs/getting-started/local

1 Like

If you have a look into that link, then you will see that the guy tried it again in 2019 and it worked. i also used this on my raspberry Pi and it worked out well. As I have written above, now I want to install it on a online-Webserver, although there should not be so much difference.

The documentation does not really show me any more information, that what I found in the tutorial. I was also on the docu before, but basically it just says

sudo npm install -g --unsafe-perm node-red

This it what gave me the errors/warnings.

I also just tried the script, which looked very promising at first, but there were still errors and I cannot access to the node-red via the http://ip:1880 after startup node-red, even as it says, the server is running

Also there were some errors during the install from the log:

## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
     echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn



WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 18.5 MB of archives.
After this operation, 94.4 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_12.x bionic/main amd64 nodejs amd64 12.20.0-1nodesource1 [18.5 MB]
Fetched 18.5 MB in 0s (56.9 MB/s)
Selecting previously unselected package nodejs.
(Reading database ... ^M(Reading database ... 5%^M(Reading database ... 10%^M(Reading database ... 15%^M(Reading dat$
Preparing to unpack .../nodejs_12.20.0-1nodesource1_amd64.deb ...
Unpacking nodejs (12.20.0-1nodesource1) ...
Setting up nodejs (12.20.0-1nodesource1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Versions: node:v12.20.0 npm:6.14.8
npm WARN using --force I sure hope you know what you are doing.
Now install Node-RED
npm WARN deprecated bcrypt@3.0.6: versions < v5.0.0 do not handle NUL in passwords properly
npm WARN deprecated request@2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated bcrypt@3.0.8: versions < v5.0.0 do not handle NUL in passwords properly
/usr/bin/node-red -> /usr/lib/node_modules/node-red/red.js
/usr/bin/node-red-pi -> /usr/lib/node_modules/node-red/bin/node-red-pi

> bcrypt@3.0.6 install /usr/lib/node_modules/node-red/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.6/bcrypt$
node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.6 and node@12.20.0 (node-v72 ABI, glibc) (falling back$
make: Entering directory '/usr/lib/node_modules/node-red/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
make: g++: Command not found
bcrypt_lib.target.mk:113: recipe for target 'Release/obj.target/bcrypt_lib/src/blowfish.o' failed
make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 127
make: Leaving directory '/usr/lib/node_modules/node-red/node_modules/bcrypt/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 4.15.0
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallba$
gyp ERR! cwd /usr/lib/node_modules/node-red/node_modules/bcrypt
gyp ERR! node -v v12.20.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/$
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/node-red/node_modules/node-pre-gyp/li$
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1022:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
node-pre-gyp ERR! System Linux 4.15.0
node-pre-gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-red/node_modules/.bin/node-pre-gyp" "install" $
node-pre-gyp ERR! cwd /usr/lib/node_modules/node-red/node_modules/bcrypt
node-pre-gyp ERR! node -v v12.20.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to$

> bcrypt@3.0.8 install /usr/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
[bcrypt] Success: "/usr/lib/node_modules/node-red/node_modules/node-red-admin/node_modules/bcrypt/lib/binding/bcrypt$
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: bcrypt@3.0.6 (node_modules/node-red/node_modules/bcrypt):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: bcrypt@3.0.6 install: `node-pre-gyp install --fallback-to-build`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ node-red@1.2.6
added 354 packages from 321 contributors in 24.118s
1.2.6
Now create basic package.json for the user and move any global nodes
Now add the shortcut and start/stop/log scripts to the menu
Now add systemd script and configure it for ssh_user
Now add launcher to top bar, add cpu temp example, make sure ping works
Memory : 2.0G
Finished : Tue Dec 8 10:45:31 UTC 2020

That looks a lot better - at least you are now on a supported version of nodejs :slight_smile:
The errors are then followed by a warning saying the optional dependency failed - which is fine as it is optional... and then it completes ok... so you should be able to run node-red-start

Thank you. That gave me some confidence to look after other reasons. I had not opened my 1880 port on the server. Actually I did it yesterday but afterwards I restored a backup from before and so the port was closed again. No I can access Node-Red. Thanks for your help.