How to run locally installed npm package with npx

Viewed 642

I have the following folder structure with the locally installed Cypress module:

cypress-test-project
  node_modules
     cypress
  tests.spec.js

As I read it in this article, npx helps to execute globally and locally installed packages:

Run a locally installed package easily

If you wish to execute a locally installed package, all you need to do is type:
$ npx your-package
npx will check whether or exists in $PATH, or in the local project binaries, and if so it will execute it.

As I have Cypress installed in the node_modules folder, I tried to run the following command:

npx cypress open

This is what I get:

No version of Cypress is installed in: C:\Users\main\AppData\Local\Cypress\Cache\9.5.1\Cypress

Please reinstall Cypress by running: cypress install

Cypress executable not found at: C:\Users\main\AppData\Local\Cypress\Cache\9.5.1\Cypress\Cypress.exe


Platform: win32-x64 (10.0.22000) Cypress Version: 9.5.1

Why does npx stop after checking the PATH variable and not looking in the local folder?

1 Answers

Cypress always installs to that user-specific (global) location even if you install locally in the project.

It sounds like the install crashed part way.

Try removing and repeating.

Related