Skip to content

Error: Cannot find module 'cypress': fail to run action on pnpm workspace. #1054

@markoleavy

Description

@markoleavy

I have a monorepo that uses pnpm workspace, structured like that

├── packages
│   ├── various services folders
│   └── test
│       ├── cypress
│       │   └──  cypress folders
│       ├── cypress.config.js
│       └── package.json
├── node_modules
├── package.json
├── pnpm-lock.yaml
└── other files

This is my job setup:

jobs:
  build-and-test:
    runs-on: ubuntu-22.04
    name: Build and test
    steps:
      - name: Checkout Code
        uses: actions/checkout@v3
      # installing pnpm and node as explained on official pnpm website
      - name: Install pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 8
          run_install: false

      - name: Setup Node 18
        uses: actions/setup-node@v3
        with:
          node-version-file: '.nvmrc'
          cache: 'pnpm'

      - name: Install dependencies
        run: |
          pnpm i --frozen-lockfile

      # other tasks running here
      
      - name: Run test
        uses: cypress-io/github-action@v6
        with:
          project: ./packages/test/
          browser: chrome

I also tried this cache config as suggested on PR #1043

jobs:
  build-and-test:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 8

      - name: Get pnpm store directory
        shell: bash
        run: |
          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
      - uses: actions/cache@v3
        name: Setup pnpm cache
        with:
          path: ${{ env.STORE_PATH }}
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-store-
      - name: Run test
        uses: cypress-io/github-action@v6
        with:
          project: ./packages/test/
          browser: chrome

That the log that the Run test action returns:

/home/runner/setup-pnpm/node_modules/.bin/pnpm install --frozen-lockfile
Scope: all 16 workspace projects

Lockfile is up to date, resolution step is skipped
Already up to date

Done in 3.4s
/opt/hostedtoolcache/node/18.12.1/x64/bin/npx cypress cache list
npm WARN exec The following package was not found and will be installed: [email protected]
┌─────────┬────────────┐
│ version │ last used  │
├─────────┼────────────┤
│ 13.3.1  │ 2 days ago │
└─────────┴────────────┘
/opt/hostedtoolcache/node/18.12.1/x64/bin/npx cypress verify

[STARTED] Task without title.
[SUCCESS] Task without title.
/usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/reponame/reponame --files-from manifest.txt --use-compress-program zstdmt
Cache Size: ~19 MB (19807[41](https://github.com/org/reponame/actions/runs/6516571247/job/17700248539#step:27:42)5 B)
Cache saved successfully
/usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/reponame/reponame --files-from manifest.txt --use-compress-program zstdmt
Cache Size: ~157 MB (16[45](https://github.com/org/reponame/actions/runs/6516571247/job/17700248539#step:27:46)55703 B)
Cache saved successfully
Error: Cannot find module 'cypress'
Require stack:
- /home/runner/work/_actions/cypress-io/github-action/v6/dist/index.js

I'm using Cypress 13.3.1 and that the config file

/* eslint-disable @typescript-eslint/no-unused-vars */
const { defineConfig } = require('cypress');

module.exports = defineConfig({
  chromeWebSecurity: false,
  fixturesFolder: false,

  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
    supportFile: false,
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions