Error "Cannot find module 'cypress'" using Yarn Berry
See original GitHub issueHi there! This action worked with yarn berry workspaces. but, this action canβt find the βcypressβ module.
Error: Cannot find module 'cypress'
I found the issue of Yarn Berry and tried as follows.
here is the relavant configuration:
jobs:
check-e2e-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Cypress run
uses: cypress-io/github-action@v2
with:
install-command : yarn install --immutable --immutable-cache
start: yarn start
wait-on: 'http://localhost:3000'
browser: chrome
headless: true
here is github-action log:
Run cypress-io/github-action@v2
with:
install-command: yarn install --immutable --immutable-cache
build: yarn run build
start: yarn start
wait-on: http://localhost:3000
browser: chrome
headless: true
record: false
config-file: cypress.json
Received 22 of 22 (100.0%), 0.0 MBs/sec
Cache Size: ~0 MB (22 B)
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/be0c8559-6dda-42c1-822d-2db565488a1c/cache.tzst -P -C /home/runner/work/*****/*****
Cache restored successfully
Received 0 of 353031365 (0.0%), 0.0 MBs/sec
Received 58720256 of 353031365 (16.6%), 28.0 MBs/sec
Received 155189248 of 353031365 (44.0%), 49.3 MBs/sec
Received 251658240 of 353031365 (71.3%), 60.0 MBs/sec
Received 344642757 of 353031365 (97.6%), 65.7 MBs/sec
Received 353031365 of 353031365 (100.0%), 61.3 MBs/sec
Cache Size: ~337 MB (353031365 B)
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/dd9a16d5-2321-41d4-9f8f-3e8284d07e08/cache.tzst -P -C /home/runner/work/*****/*****
Cache restored successfully
install command command "yarn install --immutable --immutable-cache"
current working directory "/home/runner/work/*****/*****"
/usr/local/bin/yarn install --immutable --immutable-cache
β€ YN0000: β Resolution step
Resolution step
β€ YN0000: β Completed in 0s 376ms
β€ YN0000: β Fetch step
Fetch step
β€ YN0000: β Completed in 0s 743ms
β€ YN0000: β Link step
Link step
β€ YN0000: β Completed in 0s 397ms
β€ YN0000: Done with warnings in 1s 966ms
/opt/hostedtoolcache/node/14.17.6/x64/bin/npx cypress cache list
βββββββββββ¬ββββββββββββββββββββ
β version β last used β
βββββββββββΌββββββββββββββββββββ€
β 8.4.1 β a few seconds ago β
βββββββββββΌββββββββββββββββββββ€
β 8.5.0 β a few seconds ago β
βββββββββββ΄ββββββββββββββββββββ
build app command "yarn run build"
current working directory "/home/runner/work/*****/*****"
/usr/local/bin/yarn run build
The following changes are being made to your tsconfig.json file:
- compilerOptions.paths must not be set (aliased imports are not supported)
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
74.98 KB build/static/js/2.c1fee284.chunk.js
1.71 KB build/static/js/3.b8a66e6b.chunk.js
1.17 KB build/static/js/runtime-main.2d193d74.js
1.01 KB build/static/js/main.a1fef262.chunk.js
554 B build/static/css/main.f09a1402.chunk.css
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
You may serve it with a static server:
yarn global add serve
serve -s build
Find out more about deployment here:
cra.link/deployment
start server "yarn start command "yarn start"
current working directory "/home/runner/work/*****/*****"
waiting on "http://localhost:3000" with timeout of 60 seconds
/usr/local/bin/yarn start
The following changes are being made to your tsconfig.json file:
- compilerOptions.paths must not be set (aliased imports are not supported)
βΉ ο½’wdsο½£: Project is running at http://10.1.0.5
βΉ ο½’wdsο½£: webpack output is served from
βΉ ο½’wdsο½£: Content not from webpack is served from /home/runner/work/*****/*****/public
βΉ ο½’wdsο½£: 404s will fallback to /
Starting the development server...
Compiled successfully!
You can now view ***** in the browser.
Local: http://localhost:3000
On Your Network: http://10.1.0.5:3000
Note that the development build is not optimized.
To create a production build, use yarn build.
Error: Cannot find module 'cypress'
Require stack:
- /home/runner/work/_actions/cypress-io/github-action/v2/dist/index.js
The above error occurred and was solved using with command
.
check-e2e-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Cypress run
uses: cypress-io/github-action@v2
with:
install-command : yarn install --immutable --immutable-cache
command: yarn test:e2e
here is yarn test:e2e
script:
"test:e2e": "start-server-and-test start http://localhost:3000 cypress:run",
Why canβt I find the cypress module when I use the command provided by Cypress github-action? Or did I miss something? Iβd appreciate it if you had any other advice. thank you!π
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:18 (4 by maintainers)
Top Results From Across the Web
Resolving Yarn2 + Cypress GitHub Action - Charles Stover
Error : Cannot find module 'cypress' ... This means that implementations that use command (like command: yarn cypress ) or a command-prefixΒ ...
Read more >yarn install leads to Cannot find module yarn-berry.js
Anything related to the yarn function returns this error. Have tried uninstalling and re-installing through homebrew but always results in this.
Read more >How to Fix Missing Build Script Using Cypress Github Actions?
At the moment yarn berry is not supported which will result in an error on Error Cannot find module 'cypress' using Yarn Berry...
Read more >Cannot find module 'axios' Error in TypeScript | bobbyhadz
If the error is not resolved, try to delete your node_modules and package-lock.json files, re-run npm install and restart your IDE. shell.
Read more >Migration | Yarn - Package Manager
Step by step Β· Run npm install -g yarn to update the global yarn version to latest v1 Β· Go into your project...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem is here: https://github.com/cypress-io/github-action/blob/0c9eccfb5989bd87ea58b5d8cce9a4f0db1a6d67/index.js#L621
The Cypress action runs the above
index.js
file as a Node script. It does so using NPM.require.resolve('cypress')
throws an error in Yarn 2, because theindex.js
script is running using NPM, meaning the Plug N Play file (.pnp.cjs
) is not loaded.The
index.js
file ironically looks for Yarn PNP cache files, but it has no way of using files in that cache. πTo bypass this (for now), you can use
command-prefix: yarrn dlx
to pass the defaultcypress run
command through Yarn to find it through PNP. The code path forcommand-prefix
does not userequire.resolve
, but this feels like coincidence so Iβd ask the repo owners still address this.I believe to fix this formally, the GitHub action needs to load the
.pnp.cjs
file before or during executingindex.js
.Again, for easy access:
Unblocking yourself
command-prefix: yarn dlx
to the actionβswith
.Notes for repository owners
dist/index.js
file with Yarnβs PNP file (.pnp.cjs
) so thatrequire.resolve
finds PNP modules likecypress
.I have this same issue. I donβt run the install command in the
cypress-io/github-action@v2
, but in a previous workflow run step:run: yarn install --immutable --immutable-cache
and then later:
This was working previously with yarn, but this is now yarn βberryβ (3.0.2).
I am using PnP and a Zero-Installs Yarn setup.