Skip to main content

How to install Cypress using NPM

You can directly download and install Cypress and do it using yarn but the recommended approach is to install Cypress with npm because: Cypress is versioned like any other dependency and It simplifies running Cypress in Continuous Integration.

Make sure that you have already run npm init or have a node_modules folder or package.json file in the root of your project to ensure cypress is installed in the correct directory.

$ npm install cypress --save-dev

Here --save-dev means we want to add cypress as our dev dependency in package.json. So once your team will checkout your project the cypress will be automatically installed. Even when you execute on any continuous integration server this will be installed automatically. 

Now you can open Cypress runner from your project root  using one of the following ways:

#The long way with the full path
$ ./node_modules/.bin/cypress open

# shortcut using npm bin
$(npm bin)/cypress open

#Using npx, note: npx is included with npm > v5.2 or can be installed separately.
$ npx cypress open

Several examples are automatically added. Let's run one js file and see cypress in action and it's working fine.

Tags
Submitted by tgoswami on February 23, 2021

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.