cypress: `yarn cypress open` does not open Cypress with yarn v2
Current behavior:
Not sure if this really has to do with yarn (v2) but adding the latest cypress version to a project fails for me. It successfully installs when I use npm.
Stacktrace:
➤ YN0000: ┌ Link step
➤ YN0007: │ cypress@npm:4.0.0 must be built because it never did before or the last one failed
➤ YN0009: │ cypress@npm:4.0.0 couldn't be built successfully (exit code 1, logs can be found here: /var/folders/4r/fbk_4j8d3ss5xl8975901nhr0000gp/T/logfile-6119EAzUDTs6CGBm.log)
Content of logfile-6119EAzUDTs6CGBm.log:
# This file contains the result of Yarn building a package (cypress@npm:4.0.0)
# Script name: postinstall
/.../test-cypress/.yarn/cache/any-observable-npm-0.3.0-4832f4f3ed-1.zip/node_modules/any-observable/register.js:29
throw new Error('Cannot find any-observable implementation nor' +
^
Error: Cannot find any-observable implementation nor global.Observable. You must install polyfill or call require("any-observable/register") with your preferred implementation, e.g. require("any-observable/register")('rxjs') on application load prior to any require("any-observable").
at loadImplementation (/..../test-cypress/.yarn/cache/any-observable-npm-0.3.0-4832f4f3ed-1.zip/node_modules/any-observable/register.js:29:9)
at /...../test-cypress/.yarn/cache/any-observable-npm-0.3.0-4832f4f3ed-1.zip/node_modules/any-observable/loader.js:30:18
at Object.<anonymous> (/..../test-cypress/.yarn/cache/any-observable-npm-0.3.0-4832f4f3ed-1.zip/node_modules/any-observable/index.js:2:39)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.module_1.Module._load (/..../test-cypress/.pnp.js:15569:14)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/..../test-cypress/.yarn/cache/@samverschueren-stream-to-observable-npm-0.3.0-3da2ac7de0-1.zip/node_modules/@samverschueren/stream-to-observable/index.js:2:20)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.module_1.Module._load (/..../test-cypress/.pnp.js:15569:14)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
Desired behavior:
A succesfull install
Test code to reproduce
New folder yarn init yarn add --dev cypress@4.0.0
Versions
yarn : 2.0.0-rc.27 cypress: 4.0.0 OS: macOS Catalina 10.15.3
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 10
- Comments: 25 (8 by maintainers)
@AStoker Your solution is temporary and cypress should support built-in yarn 2 (PNP algorithm) and it’s really important. We use yarn 2 for the zero-install feature to improve our CI build time, and If we use nodeLinker, we miss that feature. cc: @arcanis Do you have any plan to support cypress?
Adding some additional details (and a workaround) for those of you who are on Yarn 2. I haven’t been able to figure out exactly how Cypress starts its execution, but I was thinking that potentially the issue was revolving around node trying to identify all the modules required to actually run. Since Yarn 2 doesn’t have a node_modules folder and by default uses the PnP setup, I thought that maybe Node was doing what it does when it can’t find a library, it goes to the parent directory and looks to see if it has a node_modules folder containing what it needs, and up and up it goes.
So I decided to tell yarn to place the node_modules folder back in the directory by adding the nodeLinker plugin as recommended by the Yarn site. Now, when you run
yarn installagain, it will place all the node modules back into a folder as in Yarn 1. At this point, when runningyarn cypress openit will work as expected.In the end, I’d still like to figure out what is exactly happening here and get Cypress to run with the default PnP setup.
I ran into this - it seems like an error with a dependency relying on an older version of
rxjs. Installingrxjsandrxjs-compatseems to work around this.Cypress 9.5.1 fixed it for me with yarn 3.2 (which repro’d this issue for me before), with https://github.com/cypress-io/cypress/pull/19792.
Its seems cypress 6 is working. 7 is not. build hangs forever.
I don’t use Cypress myself, so I don’t plan to dig into that.
@maxime1992 please see my comment https://github.com/cypress-io/cypress/issues/6378#issuecomment-617552586 - your issue is unrelated to the yarn issue. Upgrade to 4.4.1 to get a fix.
@AStoker Thanks for the followup. This would explain why I was not able to replicate as I did not install Yarn 2 globally as they advise.
We do recommend the workaround in this comment for installing on Yarn 2 https://github.com/cypress-io/cypress/issues/6377#issuecomment-592742158
We will leave this issue open for the
yarn cypress openissue however.Also @AStoker - make sure you do not have
cypressglobally installed as this is the behavior if you havecypressglobally installed - to open Cypress and allow you to select project.