Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --dev mode with Yarn Modern Plug'n'Play (pnp) #30656

Open
MikeMcC399 opened this issue Nov 20, 2024 · 0 comments
Open

Support --dev mode with Yarn Modern Plug'n'Play (pnp) #30656

MikeMcC399 opened this issue Nov 20, 2024 · 0 comments
Labels
package manager: yarn Issues relating to yarn process: contributing Related to contributing to the Cypress codebase

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Nov 20, 2024

What would you like?

Following the instructions in CONTRIBUTING > Getting Started should allow selecting and running an otherwise working Cypress (E2E) project using Yarn Modern pnp without error.

Cypress however fails with the error

Your configFile is invalid

and the stack trace shows

Error: Cannot find module 'cypress'

where it presumably is trying to look for cypress in the non-existent node_modules directory, that is not created for Yarn Modern pnp configurations.

Why is this needed?

Yarn Modern Plug'n'Play is the default installation strategy for new Yarn Modern installations (in which case .yarnrc.yml > nodeLinker is undefined). Setting nodeLinker explicitly to pnp also has the same effect.

It should be possible to test the WIP Cypress develop branch against a default Yarn Modern E2E project.

The --project option is not suitable here because it uses the package.jsonfile (and by implication the package manager) of the root directory. --project does not allow to use a different package manager.

Other

Steps to reproduce error

Ubuntu 24.04.1 LTS, Node.js v22.11.0

npm install yarn@latest -g

mkdir cy-yarn-pnp-test
cd cy-yarn-pnp-test
git clone https://github.com/cypress-io/github-action
cd github-action/examples/yarn-modern-pnp
yarn
cd ../../..
git clone https://github.com/cypress-io/cypress
cd cypress
n auto # or set Node.js manually according to .node-version
yarn
yarn cypress run --project ../github-action/examples/yarn-modern-pnp --dev

Logs

$ yarn cypress run --project ../github-action/examples/yarn-modern-pnp --dev
yarn run v1.22.22
$ /home/mike/github/tmp/cy-yarn-pnp-test/cypress/node_modules/.bin/cypress run --project ../github-action/examples/yarn-modern-pnp --dev

DevTools listening on ws://127.0.0.1:39029/devtools/browser/eb4abf83-1e72-4e00-a7e7-8a4844eb6198
Your configFile is invalid: /home/mike/github/tmp/cy-yarn-pnp-test/github-action/examples/yarn-modern-pnp/cypress.config.js

It threw an error when required, check the stack trace below:

Error: Cannot find module 'cypress'
Require stack:
- /home/mike/github/tmp/cy-yarn-pnp-test/github-action/examples/yarn-modern-pnp/cypress.config.js
- /home/mike/github/tmp/cy-yarn-pnp-test/cypress/packages/server/lib/plugins/child/run_require_async_child.js
- /home/mike/github/tmp/cy-yarn-pnp-test/cypress/packages/server/lib/plugins/child/require_async_child.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/home/mike/github/tmp/cy-yarn-pnp-test/github-action/examples/yarn-modern-pnp/cypress.config.js:1:26)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at loadFile (/home/mike/github/tmp/cy-yarn-pnp-test/cypress/packages/server/lib/plugins/child/run_require_async_child.js:89:14)
    at EventEmitter.<anonymous> (/home/mike/github/tmp/cy-yarn-pnp-test/cypress/packages/server/lib/plugins/child/run_require_async_child.js:116:38)
    at EventEmitter.emit (node:events:514:28)
    at process.<anonymous> (/home/mike/github/tmp/cy-yarn-pnp-test/cypress/packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:514:28)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Related

@jennifer-shehane jennifer-shehane added process: contributing Related to contributing to the Cypress codebase package manager: yarn Issues relating to yarn labels Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package manager: yarn Issues relating to yarn process: contributing Related to contributing to the Cypress codebase
Projects
None yet
Development

No branches or pull requests

2 participants