Node JS Setup

Setting up Node.js for a project like WaSnap involves several steps to ensure a smooth development process. Here's a breakdown of the setup process:

the steps for setting up Node.js hosting account, fulfilling server requirements, deploying the project source files, updating npm, and installing and using PM2 for server management:

#Prerequisites

Before running the project, make sure you have the following installed:

#Getting Started

  • Set up Node.js Hosting Account: Choose a hosting provider that supports Node.js hosting. Sign up for an account and follow their instructions to set up a server instance.

  • Fulfill Server Requirements:

    • Ensure that the Node.js version on your server meets the project's requirements (Node version 20+).

    • Install npm and npx for dependency management. These are typically included when you install Node.js. If not, you can install them manually using the Node.js package installer.

  • Deploy Project Source Files:

    • Upload all project source files to a main directory on your server. You can use tools like FTP or SSH for file transfer.

  • Update server dependencies:

``` bash
    apt update && apt upgrade -y
```
  • Download the code to your local machine from codecanyon.net and Deploy to your server:

  ``` bash
      scp -r /Path/To/Your/App root@your_vps_ip:Path/To/Remote/Dir
  ```
  • Install dependencies :

``` bash
    npm install
```
  • Update npm:

    • Connect to your sel0rver via SSH and navigate to the directory where your project is located.

    • Run the command npm update to update npm and download any required dependencies and packages for your project.

  • Install PM2:

    • Install PM2 globally on your server using npm:

    • npm install pm2 -g
  • PM2 Commands: PM2 is a Production Process Manager for Node.js applications with a built-in Load Balancer.

After installing PM2, you can use various commands to manage your Node.js processes:

  • Start a Node.js application:

  • $ pm2 start wasnap-bot.js  (Use this command to start server)

  • Load balance multiple instances of a Node.js application:

  • $ pm2 start wasnap-bot.js  -i 4
  • Monitor PM2 processes:

  • $ pm2 monitor
  • Configure PM2 to auto-boot at server restart:

  • $ pm2 startup

For more information and advanced usage, refer to the PM2 documentation: PM2 Documentation

The server will be running at : http://your_server_url:PORT.

Node.js Server URL Details add in Laravel Project:

  • The server is built using Node.js, with the Express framework to handle HTTP requests and responses.

  • Locate the .env File: The .env file is located in the root directory of your Laravel project. Use a text editor to open the file.

  • Find APP_DOMAIN_NAME: Look for the section in the .env file that contains the APP_DOMAIN_NAME configuration variables and add your Node server URL.

Last updated