Error: Cannot find module 'cypress'

See original GitHub issue

We just attempted to update to v2 and are now getting the following error when running Cypress. Here is our action config:

jobs:
  end-to-end-tests:
    name: End-to-End tests (web)
    runs-on: ubuntu-latest
    if: github.event.pull_request.draft == false
    steps:
      ## Start Shared Setup
      - name: checkout gather
        uses: actions/checkout@v2

      - name: setup node
        uses: actions/setup-node@v2-beta
        with:
          node-version: 12.18.3

      - uses: bahmutov/npm-install@HEAD
      ## End Shared Setup

      - name: cypress in chrome
        uses: cypress-io/github-action@v2
        with:
          browser: chrome
          headless: true
      - name: upload failure screenshots
        uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: cypress-screenshots
          path: cypress/screenshots
      - name: upload failure videos
        uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: cypress-videos
          path: cypress/videos

and for reference, the previous config:

jobs:
  end-to-end-tests:
    name: End-to-End tests (web)
    runs-on: ubuntu-latest
    if: github.event.pull_request.draft == false
    steps:
      ## Start Shared Setup
      - name: checkout gather
        uses: actions/checkout@v2

      - name: setup node
        uses: actions/setup-node@v2-beta
        with:
          node-version: 12.18.3

      - uses: bahmutov/npm-install@HEAD
      ## End Shared Setup

      - name: cypress in chrome
        uses: cypress-io/github-action@v1
        with:
          browser: chrome
          headless: true
      - name: upload failure screenshots
        uses: actions/upload-artifact@v1
        if: failure()
        with:
          name: cypress-screenshots
          path: cypress/screenshots
      - name: upload failure videos
        uses: actions/upload-artifact@v1
        if: failure()
        with:
          name: cypress-videos
          path: cypress/videos

After running we get the following output:

##[debug]Cypress versions in the cache folder /home/runner/.cache/Cypress
/opt/hostedtoolcache/node/12.18.3/x64/bin/npx cypress cache list
┌─────────┬──────────────┐

│ version │ last used    │
├─────────┼──────────────┤
│ 6.0.0   │ a minute ago │
└─────────┴──────────────┘
##[debug]no need to verify Cypress binary or save caches
##[debug]No start command found
##[debug]Running Cypress tests using NPM module API
##[debug]requiring cypress dependency, cwd is /home/runner/work/calm/calm
##[debug]working directory /home/runner/work/calm/calm
##[debug]Cannot find module 'cypress'
##[debug]Require stack:
##[debug]- /home/runner/work/_actions/cypress-io/github-action/v2/dist/index.js
##[debug]Error: Cannot find module 'cypress'
##[debug]Require stack:
##[debug]- /home/runner/work/_actions/cypress-io/github-action/v2/dist/index.js
##[debug]    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
##[debug]    at Function.resolve (internal/modules/cjs/helpers.js:80:19)
##[debug]    at runTests (/home/runner/work/_actions/cypress-io/github-action/v2/dist/index.js:9094:13)
##[debug]    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Cannot find module 'cypress'
Require stack:
- /home/runner/work/_actions/cypress-io/github-action/v2/dist/index.js
##[debug]Node Action run completed with exit code 1
##[debug]CI='1'
##[debug]CYPRESS_CACHE_FOLDER='/home/runner/.cache/Cypress'
##[debug]CYPRESS_CACHE_FOLDER='/home/runner/.cache/Cypress'
##[debug]CYPRESS_CACHE_FOLDER='/home/runner/.cache/Cypress'
##[debug]TERM='xterm'
##[debug]Finishing: cypress in chrome

The above is with the following added to the action:

  ACTIONS_RUNNER_DEBUG: true
  ACTIONS_STEP_DEBUG: true

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
mikeniklescommented, Nov 25, 2020

I was forced to upgrade to v2 due to the set-env command that is now throwing an error vs. previously when it was a warning. So overall, it’s a good thing it broke and forced me to upgrade 😃.

My Cypress tests run against a live URL, so I set install: false and didn’t install any dependencies. With cypress required as a dev dependency, it looks like I now have to install my dependencies to run Cypress tests.

🤔 or… what about the following to install the cypress dependency only. Too ugly?

with:
  build: npm i -D cypress

Update: Tested that and it works. See https://github.com/mikenikles/www-mikenikles-com/pull/249

0reactions
janharmenwindcommented, Jan 21, 2022

The caching happens on the D:-drive which doesn’t exist on this pc. Could that be problem and how can I change the drive letter?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolving Yarn2 + Cypress GitHub Action - Charles Stover
An open issue exists for running the Cypress.io end-to-end test GitHub ... Error: Cannot find module 'cypress' ... Otherwise, find `cypress` and run...
Read more >
Invalid configFile (Cypress 10.0) - cannot find module
I've followed the new documentation, however Cypress is stating my file is invalid. "Error: Cannot find module 'cypress'". Here's the config I'm ...
Read more >
cypress-io/cypress - Gitter
Hi everyone, I have a question, I try to configure cypress to work with code-coverage, but I face a strange error. When I...
Read more >
Installing Cypress
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...
Read more >
Cypress Module Problem | Better world by better software
Sometimes you might see an error message when adding Cypress to an existing project that uses ES6 modules. When you run the cypress...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found