Skip to content

Cypress pre-installs not working as expected with NPM 7+ / Node 15+ #19013

@flotwig

Description

@flotwig

Current behavior

We use npm_config_argv to generate the pre-release binary URL when the binary is installed via CLI arg, like with "npm install .....cypress.tgz" or "npx ......cypress.tgz open":

// convert a prerelease NPM package .tgz URL to the corresponding binary .zip URL
const getBinaryUrlFromPrereleaseNpmUrl = (npmUrl) => {
let parsed
try {
parsed = url.parse(npmUrl)
} catch (e) {
return
}
const matches = betaNpmUrlRe.exec(parsed.pathname)
if (parsed.hostname !== 'cdn.cypress.io' || !matches) {
return
}
const { version, artifactSlug } = matches.groups
parsed.pathname = `/beta/binary/${version}/${os.platform()}-${os.arch()}/${artifactSlug}/cypress.zip`
return parsed.format()

However, npm_config_argv was removed in NPM 7: https://stackoverflow.com/a/68111110/3474615 npm/cli#1995

So this is broken for those users.

Pre-releases still work with NPM 7 if you put the cypress.tgz URL in package.json, and then run npm install.

Desired behavior

We have to hard-code the binary URL in the CLI NPM package, since npm_command does not provide the required metadata to cover this use case.

The only other way I can think would be some kind of climb up the process tree to try and read argv from parent processes, but that sounds hard to maintain.

Test code to reproduce


Cypress Version

9.0.0

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: installationIssue during installation or downloading Cypress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions