Makers Blog Archive

Installing Node.js on RFC 4072S

stijn 05 July 2019 min. read
8,162 views 0 comments

This blog explains how to install Node.js on the RFC 4072S thanks to Björn Sauer.

In order to be able to install Node.js, a root user is required. This can simply be done by executing the command:

sudo passwd root

First, fill in the password of the administor, afterwards you will be prompted to give up your new password twice.

When that is done, you can switch to the root user:

su -

Next up, we need to download Node.js from the site and unpack it in the /opt folder using the curl and tar commands.

curl -LO https://nodejs.org/download/release/v10.16.0/node-v10.16.0-linux-x64.tar.gz
tar xpf ./node-v10.16.0-linux-x64.tar.gz -C /opt

executing the chown command will now change the owner of the just untarred package.

chown -R admin:plcnext /opt/node-v10.16.0-linux-x64

When you want to have Node.js automatically added to your path, we must create a new file in the /etc/profile.d directory. To create the file with the correct content, shoot these commands into your ssh prompt

cat <<EOF > "/etc/profile.d/node.sh"
#!/bin/sh
export PATH="/opt/node-v10.16.0-linux-x64/bin:\$PATH"
EOF

run this .sh script to add the correct bins to your PATH

. /etc/profile.d/node.sh

If we would now enter the node or npm command, the controller will give an error like the one below. This is caused because the version of Node.js that we installed is a 64bit version which tries to find the /lib64 folder that is not apparant on our device. To solve this, we need to create a symbolic link /lib64 that is linked to the /lib folder.

ln -s /lib /lib64

When the link is created, the node and npm commands should work, which brings us to the last step of setting the npm prefix and return to admin user.

npm config set prefix /opt/node-v10.16.0-linux-x64 -g
exit

Thats it! You now have Node.js installed on your controller!

{jcomments on}

Note:

The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.

Discussion

Please login/register to comment

Login/Register

Leave a Reply

Newsletter
Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users