Skip to main content

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:

  1. Open the terminal.
  2. Run one of the following commands to install NVM:
    • Using curl:
      curl
      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
    • Or using wget:
      wget
      wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

2. Installing Node.js

After installing NVM, you can install Node.js.

Steps:

  1. 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:

  1. 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:

  1. Clone the application repository:
    git clone https://github.com/code-chat-br/whatsapp-api-v2.git
  2. Configure the environment variables in the .env file.

5. Installing Application Dependencies

Install the dependencies necessary for the application to function.

Steps:

  1. Navigate to the application directory:
    cd whatsapp-api-v2
  2. Install dependencies using npm:
    npm install

After following these steps, the CodeChat API application should be installed. Now configure the environment variables.