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

Yarn Modern Plug'n'Play (pnp) E2E fails with "Error: Cannot find module 'pnpapi'" #27562

Closed
MikeMcC399 opened this issue Aug 16, 2023 · 6 comments · Fixed by #27583
Closed

Yarn Modern Plug'n'Play (pnp) E2E fails with "Error: Cannot find module 'pnpapi'" #27562

MikeMcC399 opened this issue Aug 16, 2023 · 6 comments · Fixed by #27583
Assignees

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Aug 16, 2023

Current behavior

Attempting to run an E2E project based on a Yarn Modern Plug'n'Play (pnp) configuration using Cypress 12.17.4 fails with "Error: Cannot find module 'pnpapi'".

This is a regression from Cypress 12.17.3.

Desired behavior

A Cypress project based on a Yarn Modern Plug'n'Play (pnp) configuration, which previously ran successfully on Cypress 12.17.3, should continue to run successfully on later 12.x versions.

Test code to reproduce

See https://github.com/MikeMcC399/github-action/tree/test/yarn-pnp-update/examples/yarn-modern-pnp which is updated to use Cypress 12.17.4.

To run locally execute the following:

git clone --branch test/yarn-pnp-update https://github.com/MikeMcC399/github-action
cd github-action/examples/yarn-modern-pnp
npm install yarn@latest -g
yarn install
yarn run test

Cypress Version

12.17.4

Node version

18.17.1

Operating System

Ubuntu 22.04 (also reproducible on Windows 11)

Debug Logs

Oops...we found an error preparing this test file:

  > cypress/e2e/spec.cy.js

The error was:

Error: Cannot find module 'pnpapi'
Require stack:
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/enhanced-resolve/lib/ResolverFactory.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/enhanced-resolve/lib/index.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/CacheFacade.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/Compiler.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/webpack.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/index.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/cross_origin.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js
Require stack:
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/enhanced-resolve/lib/ResolverFactory.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/enhanced-resolve/lib/index.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/CacheFacade.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/Compiler.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/webpack.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/index.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/cross_origin.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js
- /home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at require$0.Module._resolveFilename (/home/runner/work/github-action/github-action/examples/yarn-modern-pnp/.pnp.cjs:10729:54)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at require$0.Module._load (/home/runner/work/github-action/github-action/examples/yarn-modern-pnp/.pnp.cjs:10641:31)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at processPnpApiOption (/home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/enhanced-resolve/lib/ResolverFactory.js:129:10)
    at createOptions (/home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/enhanced-resolve/lib/ResolverFactory.js:244:11)
    at exports.createResolver (/home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/enhanced-resolve/lib/ResolverFactory.js:259:28)
    at Object.<anonymous> (/home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/enhanced-resolve/lib/index.js:39:39)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at require$0.Module._extensions..js (/home/runner/work/github-action/github-action/examples/yarn-modern-pnp/.pnp.cjs:10796:33)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at require$0.Module._load (/home/runner/work/github-action/github-action/examples/yarn-modern-pnp/.pnp.cjs:10641:31)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/home/runner/.cache/Cypress/12.17.4/Cypress/resources/app/node_modules/webpack/lib/CacheFacade.js:8:25)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at require$0.Module._extensions..js (/home/runner/work/github-action/github-action/examples/yarn-modern-pnp/.pnp.cjs:10796:33)

This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

- A missing file or dependency
- A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests

Other

@AtofStryker
Copy link
Contributor

Hi @MikeMcC399. I think I know what may be wrong. I am going to work on getting a binary ready for us to test with what I think might fix the issue

@MikeMcC399
Copy link
Contributor Author

@AtofStryker

Thanks for your progress note!

@AtofStryker
Copy link
Contributor

OK I think I have this fixed. Binary works with local install. I have a fixed proposed in #27583

@MikeMcC399
Copy link
Contributor Author

@AtofStryker

OK I think I have this fixed. Binary works with local install. I have a fixed proposed in #27583

I would have like to have tested this whilst it was still a pending PR, however I couldn't work out how to do that for Yarn!

Now it's been merged and GitHub offers a beta I successfully tested on Windows 11. 👍🏻


yarn add cypress@https://cdn.cypress.io/beta/npm/12.17.5/win32-x64/develop-5109a74e21036dc5936369eb0a9600954ff8f377/cypress.tgz

$ yarn why cypress
└─ example-yarn-modern@workspace:.
   └─ cypress@https://cdn.cypress.io/beta/npm/12.17.5/win32-x64/develop-5109a74e21036dc5936369eb0a9600954ff8f377/cypress.tgz (via https://cdn.cypress.io/beta/npm/12.17.5/win32-x64/develop-5109a74e21036dc5936369eb0a9600954ff8f377/cypress.tgz)

$ yarn test

[40052:0822/190625.102:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[40052:0822/190625.102:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[40052:0822/190625.102:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[40052:0822/190625.102: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:58420/devtools/browser/4672151a-a4c6-40fa-913a-031a0df43270

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        12.17.5                                                                        │
  │ Browser:        Electron 106 (headless)                                                        │
  │ Node Version:   v18.17.1 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          1 found (spec.cy.js)                                                           │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  spec.cy.js                                                                      (1 of 1)


  example: yarn-modern
    √ loads the deployed site (531ms)


  1 passing (548ms)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     spec.cy.js                                                                       │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Video)

  -  Started compressing: Compressing to 32 CRF
  -  Finished compressing: 0 seconds

====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  spec.cy.js                               542ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        542ms        1        1        -        -        -

@SheldonWBM
Copy link

@MikeMcC399 The fix also works on Ubuntu

@jennifer-shehane
Copy link
Member

Released in Cypress 13.0.0.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants