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

npm postinstall fails behind an HTTPS proxy #1401

Closed
Toilal opened this issue Mar 2, 2018 · 24 comments

Comments

@Toilal
Copy link

commented Mar 2, 2018

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:
@gkemp94

This comment has been minimized.

Copy link

commented Mar 3, 2018

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

@perceboisElisa

This comment has been minimized.

Copy link

commented Mar 12, 2018

Hi,
Downloading the .zip is the best solution when downloading cypress with npm command is blocked by your corporate proxy.

@Toilal But then, could you run your app within cypress?

...because for me, I can launch cypress.exe but it is blocked due to your corporate proxy and I have currently no idea to solve this problem :-(

Regards,

@Toilal

This comment has been minimized.

Copy link
Author

commented Mar 12, 2018

I don't really use Cypress for now, it's just embedded in the default VueJS boilerplate for E2E tests.

@zerdos

This comment has been minimized.

Copy link
Contributor

commented Mar 12, 2018

Try this environment variable:

export NODE_TLS_REJECT_UNAUTHORIZED=0 
@davidsteinsland

This comment has been minimized.

Copy link

commented Mar 28, 2018

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.

@jdhines

This comment has been minimized.

Copy link

commented Apr 16, 2018

@gkemp94's answer solved it for me.

@ggarcia92

This comment has been minimized.

Copy link

commented Apr 24, 2018

@gkemp94's answer also solved it for me.

@brian-mann

This comment has been minimized.

Copy link
Member

commented Apr 24, 2018

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

@brian-mann

This comment has been minimized.

Copy link
Member

commented Apr 24, 2018

@jdhines and @ggarcia92 can you provide that as an env var during npm install or export it to your profile ahead of time?

@uriannrima

This comment has been minimized.

Copy link

commented May 15, 2018

@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)

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented May 15, 2018

@uriannrima awesome! There is some workaround documentation on this exact thing in our Epic proxy issue here: #1469

@zerdos

This comment has been minimized.

Copy link
Contributor

commented May 31, 2018

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
@squarism

This comment has been minimized.

Copy link

commented Jun 28, 2018

@zerdos My hero of the week. I was doing the binary env variable for this project but that little extra setting (which I was diving into a bunch of sources to find) worked and will likely solve future problems for me.

@dschulten

This comment has been minimized.

Copy link

commented Sep 20, 2018

In a Jenkinsfile for a Jenkins with Credentials Plugin and Credentials Binding Plugin installed and a username-password credential definition having the id PROXY_USERPASS, the following configures the proxy for cypress postinstall and does not print the credentials into the log:

    withCredentials([usernameColonPassword(credentialsId: 'PROXY_USERPASS', variable: 'USERPASS')]) 
    {
      sh '''
      set +x
      sh 'HTTPS_PROXY=http://${USERPASS}@corporate.proxy:<port> npm install'
      '''
    }

Also, caching of the cypress binary works well, it only downloads once.

@bovandersteene

This comment has been minimized.

Copy link

commented Dec 3, 2018

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

@madelson

This comment has been minimized.

Copy link

commented Apr 5, 2019

Would be great to see this fixed

@jmclocklin

This comment has been minimized.

Copy link

commented Apr 5, 2019

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

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Apr 24, 2019

@flotwig Another potential proxy issue. Is this not fixed in 3.3.0 PR? #3531

@flotwig

This comment has been minimized.

Copy link
Member

commented Apr 24, 2019

@jennifer-shehane This issue should be fixed by #3531, since now we have support for proxies and NODE_EXTRA_CA_CERTS is automatically dealt with by node in tls, so we don't have to do anything special.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Apr 24, 2019

The code for this is done in #3531, but this has yet to be released. We'll update this issue and reference the changelog when it's released.

@JMclovin

This comment has been minimized.

Copy link

commented May 8, 2019

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

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented May 13, 2019

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.

@oskarTeodor

This comment has been minimized.

Copy link

commented May 14, 2019

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.

@IonicOnCouch

This comment has been minimized.

Copy link

commented May 27, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.