cypress-io / cypress-documentation

Cypress Documentation including Guides, API, Plugins, Examples, & FAQ.
https://docs.cypress.io
MIT License
940 stars 1.04k forks source link

Cypress npm install with snap Node.js on Ubuntu fails to install Cypress binary #5868

Closed MikeMcC399 closed 2 months ago

MikeMcC399 commented 2 months ago

Subject

Guides https://docs.cypress.io/guides/getting-started/installing-cypress#npm-install

Description

If an attempt is made to install Cypress on Ubuntu using npm that has been installed via snap Node.js, then it fails to install the Cypress binary.

For example:

sudo snap install node --classic --channel=20
npm install cypress --save-dev

Typical log lines include output similar to the following:

npm info run cypress@13.13.0 postinstall node_modules/cypress node index.js --exec install
npm info run cypress@13.13.0 postinstall { code: 1, signal: null }
...
npm error command sh -c node index.js --exec install

If this is an on-going restriction, then it may need to be documented here. A workaround is to use:

npm install cypress --save-dev --foreground-scripts

Yarn is not affected. The following works correctly:

yarn add cypress -D
jennifer-shehane commented 2 months ago

Sounds fine to document for now.

MikeMcC399 commented 2 months ago

@jennifer-shehane

Sounds fine to document for now.

It will be a while until I get around to this. I hope there will be some feedback soon from the Node.js snap folks to understand the root cause and who could fix it. For the moment I just wanted to document the issue so there is a place to add any new facts.

MikeMcC399 commented 2 months ago
MikeMcC399 commented 2 months ago

Workaround Verification

Ubuntu 22.04.4 LTS

snap install node --classic --channel=20
echo node version $(node -v)
echo npm version $(npm -v)
rm -rf ~/.cache/Cypress
mkdir cy-snap-test
cd cy-snap-test
npm install cypress --save-dev --foreground-scripts
npx cypress verify

Log

$ snap install node --classic --channel=20
echo node version $(node -v)
echo npm version $(npm -v)
rm -rf ~/.cache/Cypress
mkdir cy-snap-test
cd cy-snap-test
npm install cypress --save-dev --foreground-scripts
npx cypress verify
node (20/stable) 20.15.1 from OpenJS Foundation (iojs✓) installed
node version v20.15.1
npm version 10.7.0

> cypress@13.13.0 postinstall
> node index.js --exec install

Installing Cypress (version: 13.13.0)

✔  Downloaded Cypress
✔  Unzipped Cypress
✔  Finished Installation /home/mike/.cache/Cypress/13.13.0

You can now open Cypress by running: node_modules/.bin/cypress open

https://on.cypress.io/installing-cypress

added 173 packages in 37s

39 packages are looking for funding
  run `npm fund` for details

✔  Verified Cypress! /home/mike/.cache/Cypress/13.13.0/Cypress
MikeMcC399 commented 2 months ago

@jennifer-shehane

Sounds fine to document for now.

There wasn't any indication that the snap folks would look at resolving the Cypress installation issue in this environment, so there is no timeline at all for a resolution. It therefore makes sense to document the workaround.