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

Cypress does not detect required dependencies during launch with Yarn 3 in PnP mode #30017

Closed
pondchamp opened this issue Aug 11, 2024 · 2 comments

Comments

@pondchamp
Copy link

pondchamp commented Aug 11, 2024

Current behavior

[Similar issue to what was mentioned in a discussion thread (#27263), though it never got any responses]

I recently started encountering a missing dependency error when launching Cypress with Yarn 3.2.3 in PnP mode (see debug logs).

I tried reverting to Cypress 12.3.0, but I get the same error except for lodash instead of @opentelementry\resources.

I discovered that temporarily setting nodeLinker: node-modules on my .yarnrc.yml file allows Cypress to launch successfully, though it isn't very practical for development purposes given our entire site uses PnP. Is there anything I can do to get Cypress working in PnP mode?

Desired behavior

Application should launch without needing to use node_modules linker

Test code to reproduce

  1. Create a React app with Yarn 3 on PnP linker mode
  2. Install and launch Cypress

Cypress Version

13.13.2

Node version

v16.20.2 (also tested with Node v18.x)

Operating System

Win11 22631.3880

Debug Logs

> yarn cypress:run

[13432:0810/174402.026:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[13432:0810/174402.026:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[13432:0810/174402.026:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[13432:0810/174402.026:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.

DevTools listening on ws://127.0.0.1:64622/devtools/browser/4a5e315f-bae4-45d5-8052-e1cb3fed781e
E:\code\syai\FolikoWeb\.pnp.cjs:29537
      Error.captureStackTrace(firstError);
            ^

Error: Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @opentelemetry/resources (via "@opentelemetry\resources")
Required by: C:\Users\julia\AppData\Local\Cypress\Cache\12.17.3\Cypress\resources\app\node_modules\@packages\telemetry\dist\

Require stack:
- C:\Users\julia\AppData\Local\Cypress\Cache\12.17.3\Cypress\resources\app\node_modules\@packages\telemetry\dist\node.js
- C:\Users\julia\AppData\Local\Cypress\Cache\12.17.3\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\require_async_child.js
    at Function.require$$0.Module._resolveFilename (E:\code\syai\FolikoWeb\.pnp.cjs:29537:13)
    at Function.require$$0.Module._load (E:\code\syai\FolikoWeb\.pnp.cjs:29391:42)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (C:\Users\julia\AppData\Local\Cypress\Cache\12.17.3\Cypress\resources\app\node_modules\@packages\telemetry\dist\node.js:4:21)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Object.require$$0.Module._extensions..js (E:\code\syai\FolikoWeb\.pnp.cjs:29581:33)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.require$$0.Module._load (E:\code\syai\FolikoWeb\.pnp.cjs:29421:14)

Other

No response

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Aug 11, 2024

@pondchamp

PS Sorry for my incorrect post linking this issue to Component Testing, which I deleted after posting, since it was irrelevant.

@pondchamp
Copy link
Author

@pondchamp

PS Sorry for my incorrect post linking this issue to Component Testing, which I deleted after posting, since it was irrelevant.

Thanks for the help @MikeMcC399! I did some digging and .pnp.cjs was indeed my issue - though to generalise the solution here, I found that having this file at my drive root was the cause of my issue, so I think it's just a matter of having the file in any parent directory. Will look into the yarn upgrade to see if it also resolves the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants