How to install a Discord bot based on Node.JS?
It is recommended to perform the instructions below on a clean server, right after (re)installation. Click Reinstallation in the panel to do this.
Installing Node.JS
Before starting, make sure curl is installed on the system. If curl is not installed, it can be installed with the following command:
apt install -y curl
Run the installation script:
You can replace the number 23 in the command below with the version of Node.JS you need.
curl -fsSL https://deb.nodesource.com/setup_23.x | bash -
apt install -y nodejs npm
Verify the installed version:
node -v
Verify the bot works correctly:
node index.js
Replace index.js with the main file of your bot - it may be different!
Running the bot in the background with PM2
PM2 is a daemon process manager that helps manage your application and keep it online. Getting started with PM2 is simple, it is offered as a simple and intuitive CLI, installed via NPM.
Install PM2
npm install pm2@latest -g
Run the bot in the background:
npm start index.js