Installation
To install and configure the CodeChat API application on the Node.js server, follow the steps detailed below:
1. Installing NVM (Node Version Manager)
NVM (Node Version Manager) is a tool that allows you to install and manage multiple versions of Node.js. This is useful for ensuring compatibility between different projects.
Steps:
- Open the terminal.
- Run one of the following commands to install NVM:
- Using
curl
:curlcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
- Or using
wget
:wgetwget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
- Using
2. Installing Node.js
After installing NVM, you can install Node.js.
Steps:
- In the terminal, install a specific version of Node.js (e.g. version 20) using NVM:install node
nvm install 20
3. Installing PM2 (Process Manager)
PM2 is a process manager for Node.js applications. It helps keep the application active, automatically restarting it in case of failures.
Steps:
- Install PM2 globally using npm:
npm install -g pm2
4. Initializing the Application
Before starting the application, you need to configure the environment variables.
Steps:
- Clone the application repository:
git clone https://github.com/code-chat-br/whatsapp-api-v2.git
- Configure the environment variables in the
.env
file.
5. Installing Application Dependencies
Install the dependencies necessary for the application to function.
Steps:
- Navigate to the application directory:
cd whatsapp-api-v2
- Install dependencies using npm:
npm install
After following these steps, the CodeChat API application should be installed. Now configure the environment variables.