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

Dependencies are not detected during onboarding when using Yarn 3 #25960

Closed
lmiller1990 opened this issue Feb 27, 2023 · 6 comments · Fixed by #26452
Closed

Dependencies are not detected during onboarding when using Yarn 3 #25960

lmiller1990 opened this issue Feb 27, 2023 · 6 comments · Fixed by #26452
Assignees
Labels
CT Issue related to component testing

Comments

@lmiller1990
Copy link
Contributor

Related: #22747 -> #22747 (comment)

Repro:
yarn3.zip

I have Vue and Vite installed (specified via package.json) but no node_modules since I'm using Yarn 3 PnP. The dependences are not detected.

You can skip them and continue, but it's not a great experience.

image

@lmiller1990
Copy link
Contributor Author

@astone123
Copy link
Contributor

Should be able to use the PnP API for this

@mike-plummer
Copy link
Contributor

@astone123 It looks like the resolve-package-path package we're using for dependency resolution already tries to use pnpapi if it's available - maybe there's some additional config we need to enable to make sure the pnp system is enabled?

@lmiller1990
Copy link
Contributor Author

It looks like pnpapi isn't found - it hits this line: https://github.com/stefanpenner/resolve-package-path/blob/b50d56f270ee3625cf7d96420f630b23510fefc8/src/index.ts#L30

According to yarn docs

This error message is not generated by Plug’n’Play. Ever. If you get it, it very likely means that your application is not running with the PnP resolver, meaning that your require calls won’t be able to load files from your dependencies (since the node_modules needed for the regular Node resolution won’t have been generated). Make sure to either run your code using NODE_OPTIONS="--require /path/to/.pnp.js" or to call it using yarn node which does the right thing transparently (whether you’re using PnP or not).

I tried adding NODE_OPTIONS

 NODE_OPTIONS=-"-require=../../dump/y3/.pnp.cjs"  yarn cypress:open --project ~/code/dump/y3

Same thing:

error An unexpected error occurred: "Cannot find module 'pnpapi'
Require stack:
- /Users/lachlanmiller/.cache/node/corepack/yarn/1.22.19/lib/cli.js
- /Users/lachlanmiller/.cache/node/corepack/yarn/1.22.19/bin/yarn.js
Require stack:
- /Users/lachlanmiller/.cache/node/corepack/yarn/1.22.19/lib/cli.js
- /Users/lachlanmiller/.cache/node/corepack/yarn/1.22.19/bin/yarn.js".
info If you think this is a bug, please open a bug report with the information provided in "/Users/lachlanmiller/code/work/cypress2/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation

Not sure what's next - it looks like when Cypress runs, the electron process needs to be aware that

  1. user is on yarn 3
  2. where to find .pnp.cjs
  3. where to look for node_modules (usually in <HOME>.yarn/berry/cache - not sure if this info is available from .pnp.cjs or elsewhere

@lmiller1990 lmiller1990 self-assigned this Apr 6, 2023
@lmiller1990
Copy link
Contributor Author

I found out pnpapi is available if I do yarn node. Read that here: https://yarnpkg.com/features/pnp#initializing-pnp

Might need a special check for PnP when we kick off Cypress.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 17, 2023

Released in 12.10.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.10.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CT Issue related to component testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants