Search code examples
node.jsbashnpmcypresssh

Bash script failing to execute NPM scripts for Cypress


I am running into an issue with a bash script I made. For context, I have written NPM scripts to run Cypress tests on the command line. My goal is to have a bash script that runs each of these NPM scripts, and executes Cypress in the command line. Also for reference, my script.sh is located in the project folder.

If I run my NPM scripts manually from my terminal, there's no issue. Cypress works. Here is an example of an NPM script I have:

"cypress:window": "./node_modules/.bin/cypress open",

The problem is when I put those commands into a bash script. Now, when script.sh runs it executes with code=1 and does not actually run Cypress at all. My script.sh is just:

npm run cypress:window

Solution

  • this was an issue with my .sh entirely. The solution was to ensure the file had executable rights. Thanks for the help!