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 · 31 comments
Closed

npm postinstall fails behind an HTTPS proxy #1401

Toilal opened this issue Mar 2, 2018 · 31 comments

Comments

@Toilal
Copy link

@Toilal Toilal 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
Copy link

@gkemp94 gkemp94 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
Copy link

@perceboisElisa perceboisElisa 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
Copy link
Author

@Toilal Toilal 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
Copy link
Contributor

@zerdos zerdos commented Mar 12, 2018

Try this environment variable:

export NODE_TLS_REJECT_UNAUTHORIZED=0 

@davidsteinsland
Copy link

@davidsteinsland davidsteinsland 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
Copy link

@jdhines jdhines commented Apr 16, 2018

@gkemp94's answer solved it for me.

@ggarcia92
Copy link

@ggarcia92 ggarcia92 commented Apr 24, 2018

@gkemp94's answer also solved it for me.

@brian-mann
Copy link
Member

@brian-mann brian-mann 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
Copy link
Member

@brian-mann brian-mann 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
Copy link

@uriannrima uriannrima 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
Copy link
Member

@jennifer-shehane jennifer-shehane commented May 15, 2018

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

@zerdos
Copy link
Contributor

@zerdos zerdos 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
Copy link

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

@dschulten dschulten 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
Copy link

@bovandersteene bovandersteene 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
Copy link

@madelson madelson commented Apr 5, 2019

Would be great to see this fixed

@jmclocklin
Copy link

@jmclocklin jmclocklin commented Apr 5, 2019

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

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Apr 24, 2019

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

@flotwig
Copy link
Member

@flotwig flotwig 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
Copy link
Member

@jennifer-shehane jennifer-shehane 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
Copy link

@JMclovin JMclovin 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
Copy link
Member

@jennifer-shehane jennifer-shehane 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
Copy link

@oskarTeodor oskarTeodor 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
Copy link

@IonicOnCouch IonicOnCouch commented May 27, 2019

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

@datdoan
Copy link

@datdoan datdoan commented Jun 25, 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

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

@HackPoint
Copy link

@HackPoint HackPoint commented Jun 30, 2019

@datdoan how it is done in MAC, still unable to install cypress?

@datdoan
Copy link

@datdoan datdoan commented Jun 30, 2019

Hi @HackPoint,

For Mac follow @IonicOnCouch steps below:

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

@trip-S
Copy link

@trip-S trip-S commented Apr 22, 2020

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

Hello, can someone please give more details on how to set this ? Is it env variable ? full detailed step by step guide please. I am new to this. thank you

@IonicOnCouch
Copy link

@IonicOnCouch IonicOnCouch commented Apr 22, 2020

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

Hello, can someone please give more details on how to set this ? Is it env variable ? full detailed step by step guide please. I am new to this. thank you

Hi sidcyrus,

  1. Download the binary manually here: https://download.cypress.io/desktop
  2. Open a Terminal-Window
  3. Navigate to your project-directory
  4. Remove the folder "node_modules" in your project-directory if it's exists
  5. Remove the file "package-lock.json" in your project-directory if it's exists
  6. Run these command in your Terminal: CYPRESS_INSTALL_BINARY=/path/to/zipfile/cypress.zip npm install cypress --save-dev

@trip-S
Copy link

@trip-S trip-S commented Apr 23, 2020

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

Hello, can someone please give more details on how to set this ? Is it env variable ? full detailed step by step guide please. I am new to this. thank you

Hi sidcyrus,

1. Download the binary manually here: https://download.cypress.io/desktop

2. Open a Terminal-Window

3. Navigate to your project-directory

4. Remove the folder "node_modules" in your project-directory if it's exists

5. Remove the file "package-lock.json" in your project-directory if it's exists

6. Run these command in your Terminal: `CYPRESS_INSTALL_BINARY=/path/to/zipfile/cypress.zip npm install cypress --save-dev`

Thanks But I still get errror.
CYPRESS_INSTALL_BINARY=/path/to/zipfile/cypress.zip : The term
'CYPRESS_INSTALL_BINARY=/path/to/zipfile/cypress.zip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I even tried giving path of the folder where cypress.zip is to replace the '/path/to/zipfile/' in above command. I am in the directory where I want to install cypress.
Thank you for your help.

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Apr 27, 2020

This was released in 3.3.0. This issue will be closed to further comment as the exact issue here was resolved and tested.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet