-1

When I enter command C:\Users\gurpr\Documents\Cypress_demo>node_modules\.bin\cypress open, I am getting the error

    Error: Cannot find module 'C:\Users\gurpr\Documents\Cypress_demo\node_modules\cypress\bin\cypress'
    [90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)[39m
     [90m    at Function.Module._load (internal/modules/cjs/loader.js:690:27)[39m
    [90m    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)[39m
    [90m    at internal/main/run_main_module.js:17:11[39m {
      code: [32m'MODULE_NOT_FOUND'[39m,
      requireStack: []
    }
Ann Kilzer
  • 1,266
  • 3
  • 16
  • 39
user12599899
  • 21
  • 1
  • 1

2 Answers2

2

Install Cypress Globally(not recommended)
In order for cypress open to work as you expect, you need to install cypress globally npm install cypress -g. I'm not positive why Cypress discourages this, but it probably relates to versioning. If you globally install and use cypress open you could be using a different version than the one specified in the package.json. Your team will get frustrated if you have different results when you run the test with your globally installed cypress instance while they run cypress with the package.json version. Command line will also behave differently. I wouldn't do this.

Use npx to Open/run Cypress
I use npx cypress open or npx cypress run in my package.json script definitions.

Uninstall Cypress Globally
You want to avoid saying "works on my machine..." to your team. I would uninstall cypress globally if you haven't. npm uninstall cypress -g

NANfan
  • 449
  • 3
  • 16
-1

You can install cypress using npm install cypress -g and open using: cypress open

I would recommend to use this way if you are installing cypress only for practice point of view. It would solve your problem.

Roman Truba
  • 4,401
  • 3
  • 35
  • 60
Sweety Sharma
  • 121
  • 1
  • 2
  • 3