Installation

Before getting started with whatsapp-web.js, it's essential for you to install Node.js and whatsapp-web.js itself on your machine. Please note that whatsapp-web.js v1 requires Node v18 or higher.

TIP

To check if you already have Node installed on your machine, run node -v in your terminal. If the output is v18 or higher, then you're good to go! Otherwise you should continue reading.

WARNING

If you already have Node installed, but you are using an older version that is below v18, you need to upgrade your Node version too. You can do this by installing the nvmopen in new window.

Installing Node.js

Installation on Windows

Installing Node on Windows works just like any other program.

  1. Download any version above 18+open in new window from the official Node.js website.
  2. After the download is complete, open the downloaded file and follow the installer steps.
  3. Once the installation is complete, you can use Node.js and npm in your terminal.

Installation on macOS

Installing Node on macOS is as easy as with installing Node on Windows.

  1. Download any version above 18+open in new window from the official Node.js website.
  2. After the download is complete, open the downloaded file and follow the installer steps.
  3. Once the installation is complete, you can use Node.js and npm in your terminal.

You can also install Node.js using Homebrewopen in new window, if you have that already installed.

# Run this command in your terminal
brew install node

Installation on Linux

You can install Node.js on Linux using the package manageropen in new window of your choice.

Installation on no-gui systems

If want to installing whatsapp-web.js on a system without a GUI, such as a linux server image, and you need puppeteer to emulate the Chromium browser, there are a few additional steps you'll need to take.

First, you'll need to install dependencies required by puppeteer, such as the necessary libraries and tools for running a headless Chromium browser.

sudo apt install -y gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

After installing these dependencies, you can proceed with installing whatsapp-web.js and puppeteer as usual. When puppeteer installs, it will download a version of Chromium suitable for headless environments.

Setup essentials

After installed Node, you can now run commands in your terminal. We recommend using npmopen in new window(Node's package manager) that comes bundelt with every Node installation. However, you have the option to use either Yarnopen in new window or pnpmopen in new window as your package manager. The guide supports all three package managers in the examples.

Choose an editor

As for code editors, you have the freedom to choose any editor you prefer. However, we recommend Visual Studio Codeopen in new window. It's a free and open-source editor available for Windows, macOS, and Linux. Visual Studio Code offers a plethora of features, extensions, and a vibrant community, making it immensely popular and user-friendly.

If you don't find VSC appealing, you can explore a list of other code editors here:

Create your project folder

TIP

Setup via Terminal

Depending on your preference, you can create a new project folder using the terminal.

The folder is created on your directory you are currently located in. You can navigate to the location of your choice on your machine via cd path/to/your/folder and create a new folder.

mkdir wwebjs-bot
cd wwebjs-bot

Navigate to the location of your choice on your machine and create a new folder named wwebjs-bot (or whatever you want) for your project. Next you'll need to open your terminal in your folder.

TIP

If you use Visual Studio Codeopen in new window, you can press Ctrl + ` to open its integrated terminal.

With the terminal open, run the node -v command to ensure that you've successfully installed Node.js. If it outputs v18 or higher, you're all set! If not, you should consider reinstalling Node.js and following the installation steps again.

Initialize your project

npm init
yarn init
pnpm init

This command creates a package.json file for your project, which will keep track of the dependencies your project uses, as well as other information. When you run it, it will ask you a series of questions. You should fill them out according to your project's needs. If you're unsure about something or want to skip it entirely, you can leave it blank and press Enter.

TIP

For a quick start, simply run the following command to automatically fill in all the details for you.

npm init -y
yarn init -y
pnpm init -y
Example `package.json` file
{
  "name": "wwebjs-bot",
  "version": "1.0.0",
  "description": "This is a simple example for this library.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Once you've completed that step, you're all set to install whatsapp-web.js!

Installing whatsapp-web.js

Now that you have your project folder set up, you can install whatsapp-web.js. To do this, open your terminal again within your folder and execute the following command:

npm install whatsapp-web.js
yarn add whatsapp-web.js
pnpm add whatsapp-web.js

In your console, the downloading progress will now be displayed. Once the download is completed, you'll be ready to start with your project.