This article will show you how to install Node.js and the Node Package Manager to your slot for use with applications.
You'll need to execute some commands via SSH to use this software. There is a separate guide on how to connect to your slot via SSH. Commands are kept as simple as possible and in most cases will simply need to be copied and pasted into the terminal window (then executed by pressing the Enter key).
To install Node.js and its package manage (npm) simply log in via SSH and copy-paste the following commands:
mkdir -p ~/bin && bash wget -qO ~/node.js.tar.gz https://nodejs.org/dist/v11.15.0/node-v11.15.0-linux-x64.tar.gz tar xf ~/node.js.tar.gz --strip-components=1 -C ~/ mkdir -p ~/node/apps cd && rm -rf node.js.tar.gz
Due to the way versions of Node.js are hosted it's not possible to provide a link which would always download the most up-to-date version. Feel free to contribute to this page by updating the URL above.
The installation process also creates a directory for apps at ~/node/apps. This isn't necessary but can help to keep things neat. Guides to software such as Flood assume this as well.
Running Node.js and NPM
You can install the latest stable release of a package and its dependencies with npm install --production --prefix ~/node/apps/directory, where directory is replaced by the name of the directory housing the desired app.
To start an app, run npm start --prefix ~/node/apps/directory, where directory is replaced by the name of the directory housing the desired app.
You can check which version is installed with node -v.
- When I run node I get an error bash: node: command not found
This means ~/bin is not part of your PATH. You can add it with the following:
echo "PATH=~/bin:$PATH" > ~/.bashrc source ~/.bashrc
Then, try the node command again.
rm ~/bin/node ~/bin/npm ~/bin/npx ~/node