• Money Tips | Product Reviews

Installing Cypress using NPM | Complete Guide

Updated: Jul 4

npm Cypress installation guide

Image credit: Github

How do I install Cypress using npm?

You can install the Cypress testing tool with this npm cypress command.

npm install cypress --save-dev

But wait, before you go ahead and run that command, make sure you are in the right directory and other checks to do.

System requirements:

As mentioned in the official Cypress documentation, the following OS is supported.

  • macOS 10.9 and above (64-bit only)

  • Linux Ubuntu 12.04 and above, Fedora 21 and Debian 8 (64-bit only)

  • Windows 7 and above

Install npm

npm is installed with node.js. First, install node.js to get the npm tool. Note that only Node.js 12 or 14 is supported.

For Linux machines, run this command to install the additional software. You will quickly recognize some of the names in this command like xvfb which is needed for Cypress to work properly in Linux.

apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb

Step 1:

Cypress is supported for macOS, Windows, and Linux. SO depending on which OS you have, you can install 64-bit or 32-bit. But don't worry about this. The right bit will be selected base on your OS automatically!

First, CD to project directory which is the folder where you are installing the Cypress dependency:

cd /your/project/directory

Run npm init command in this directory so it creates the necessary folders and files (node_modules folder and package.json file)

npm init 

Step 2:

Run this command:

npm install cypress --save-dev

Now, you will see that Cypress will be installed as a dev dependency. Open your package.json file and check that you have a cypress entry with the version number as a dev dependency.

cypress command prompt install

Once it is installed, you can navigate to the node_modules/.bin folder and run the cypress open c command to open the tool

cypress open

running cypress tool using a command

npm is the recommended way to install Cypress. There are other ways like using yarn to install this testing tool.

What tests can I write using Cypress?

With Cypress, you can write the following types of tests:

  • End-to-end tests

  • Integration tests

  • Unit tests


Now that you have installed Cypress, you can write automated tests for Chrome, Firefox, or Edge. Be sure to check their documentation to see what browsers and versions are supported.