cypress: npm postinstall fails behind an HTTPS proxy

Current behavior:

I’m running behind an HTTPS corporate proxy configured with a self-signed certificate. This requires to setup the self-signed certificate with NODE_EXTRA_CA_CERTS environment variable.

yarn install cypress gives the following error (same with npm)

> cypress@2.1.0 postinstall /app/oison-frontend/node_modules/cypress
> node index.js --exec install

Installing Cypress (version: 2.1.0)

 ✖  Downloading Cypress
   → Cypress Version: 2.1.0
    Unzipping Cypress
    Finishing Installation
The Cypress App could not be downloaded.

Please check network connectivity and try again:
----------

URL: https://download.cypress.io/desktop/2.1.0?platform=linux&arch=x64
Error: self signed certificate in certificate chain
----------

Platform: linux (Debian - 8.10)
Cypress Version: 2.1.0

It seems NODE_EXTRA_CA_CERTS is not honored by the post installation script downloading cypress binary.

Desired behavior:

It should work

How to reproduce:

Come to my company and have fun configuring this proxy sh*t.

Additional Info (images, stack traces, etc)

It was working yesterday, so I think something has changed in the package of 2.1.0 release.

  • Operating System: Ubuntu
  • Cypress Version: >=2.1
  • Browser Version:

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 22
  • Comments: 31 (8 by maintainers)

Most upvoted comments

I had this problem a few days ago and found that the best workaround was to download the zip file directly from the site then type the following command before attempting npm install. This should then install the file from your zip file. Hope that helps.

CYPRESS_BINARY_VERSION=/local/path/to/cypress.zip

Cypress should (at least) honor the following env vars, which is the de facto way of configuring proxy:

  • HTTP_PROXY / http_proxy
  • HTTPS_PROXY / https_proxy

Also, because it’s node:

  • NODE_EXTRA_CA_CERTS

And perhaps also the following npm configs:

  • cafile
  • https-proxy
  • proxy

Stuff like setting NODE_TLS_REJECT_UNAUTHORIZED=0 or similar is out of the question, and defeats the whole purpose of secure connections.

so, if you have man in the middle corporate proxy, you can add the extra certificate as an environment variable.

It’s solved our problem.

example:

NODE_EXTRA_CA_CERTS=./ssl/mitn.pem yarn

Try this environment variable:

export NODE_TLS_REJECT_UNAUTHORIZED=0 

I had this problem a few days ago and found that the best workaround was to download the zip file directly from the site then type the following command before attempting npm install. This should then install the file from your zip file. Hope that helps.

CYPRESS_BINARY_VERSION=/local/path/to/cypress.zip

From version 3.x.x you chould use export CYPRESS_INSTALL_BINARY=/Users/bvd1n4r/Downloads/cypress.zip

@uriannrima awesome! There is some workaround documentation on this exact thing in our Epic proxy issue here: https://github.com/cypress-io/cypress/issues/1469

1. Download the binary manually here: https://download.cypress.io/desktop 2. npm isntall: CYPRESS_INSTALL_BINARY=/path/to/zipfile/cypress.zip npm install cypress --save-dev

For windows: SET CYPRESS_INSTALL_BINARY=/path/to/zipfile/cypress.zip npm install cypress

We’re working on patching up fixes to release this as fast as we can. The introduction of the proxy code brought up some regressions we needed to address before releasing.

@jennifer-shehane Any time frame when this fix might be release as this issue is stopping us from using cypress in our environments

This issue is blocking us from using Cypress - a fix would be super useful.

1. Download the binary manually here: https://download.cypress.io/desktop 2. npm install: CYPRESS_INSTALL_BINARY=/path/to/zipfile/cypress.zip npm install cypress --save-dev

For anyone that’s stuck waiting for the patch I have a solution for local testing that works for me.

  1. Download the latest version of Cypress via Direct download : https://on.cypress.io/installing-cypress#Direct-download
  2. Install and place the Cypress folder at the location of your older versions of Cypress for me it’s in: C:\Users\oskar\AppData\Local\Cypress\Cache\3.2.0 (Important; you have to have the same folder structure --> 3.2.0\Cypress\{content of cypress install}
  3. Change the package.json in your project to match Cypress version 3.2.0 --> run yarn install (npm install) in your project
  4. Start using Cypress as before e.g. yarn cypress run

I have tried this setup on two different windows machine and it works on both.

Would be great to see this fixed

@brian-mann I was having the same issue of ECONNREFUSED for being behind corporate proxy, had already configured PROXY and HTTP-PROXY on npm config list, but it still ocurred. Configured HTTP_PROXY and HTTPS_PROXY on system environments and it finally downloaded successfully.

(It was needed to use @vue/cli template)

@davidsteinsland Cypress should already support the HTTP_PROXY and HTTPS_PROXY env vars since it uses request under the hood to download the binary…