How to set no proxy in yarn - yarnpkg

I am trying to install packages from within the corporate network along with some packages that exist within the corporate repository. I was able to configure the following proxy settings for yarn
yarn config set proxy "${PROXY}"
yarn config set https-proxy "${PROXY}"
But since some packages exist within the corporate network installing them fails. I couldnt find a way to set no proxy for internal corporate urls. There is a workaround posted here - https://github.com/yarnpkg/yarn/issues/5048#issuecomment-604181595. But I would like to know if there is a better way

yarn doesn't seem to to have a concept of no proxy. It either tries to proxy everything or nothing...very naive. Fortunately, npm does so we use npm for all of our projects.

Related

Install collection dependencies in ansible with differing proxy settings

Problem: I want to install a collection via ansible-galaxy, but one needs a proxy and the other one does not
galaxy.html of the needed collection:
dependencies:
community.docker: 2.4.0
git+https://gitlab.test.org/collections/test: master
In this example, community.docker needs a proxy to be installed, the other one fails if a proxy is set.
Is there a possibility to unset the proxy or set the proxy for a dependency in the galaxy.yml file?
Setting the no_proxy environment variable on the controller is a fine solution for this problem.
export no_proxy=gitlab.test.org
It can get rather aggregious to do this though if you have similar names for your gitlab instances, but worked for me.

Using Artifactory to proxy Cypress with CYPRESS_DOWNLOAD_MIRROR

Desired behavior
I would like to use CYPRESS_DOWNLOAD_MIRROR pointing toward my artifactory configuration for Cypress and just be able to do npm install and download library AND binary of Cypress
Current behavior
When setting Cypress in artifactory, and downloading it with CYPRESS_DOWNLOAD_MIRROR set toward this tool, the download script find binary files as X.Y.Z and not cypress.zip and fail. Apparently I can't rename binaries in artifactory. It seems to have made it available in a name X.Y.Z instead of cypress.zip
My artifactory admin tell me to do this command before but I can't since it's a post action of Cypress
curl –v « https://artifactory.mycompany.fr/artifactory/remote-download.cypress-generic/desktop/6.8.0?platform=win32&arch=x64 » > cypress.zip
Workaround
For now, I'm using CYPRESS_INSTALL_BINARY to point to a manually uploaded binary in artifactory but it's a pain because I have to separate Linux binary (for CI) and Windows binary (for dev) and if my package is configured with "cypress": "^6.2.1" the npm library will go to 6.2.1 and my binary will stuck to 6.2.0 for example...
Debug logs
Installing Cypress (version: 6.8.0)
× Downloading Cypress
→ Cypress Version: 6.8.0
Unzipping Cypress
Finishing Installation
The Cypress App could not be downloaded.
Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading
Cypress. Read more: https://on.cypress.io/proxy-configuration
Otherwise, please check network connectivity and try again:
URL: https://artifactory.mycompany.fr/artifactory/remote-download.cypress.io/desktop/6.8.0?platform=win32&arch=x64
Error: self signed certificate in certificate chain
Download method
npm
Operating System
Linux
Windows
Other
I'm behind a proxy
I don't really know if it's an artifactory or a Cypress matter but I need help ^^
In addition to accepted answer, it is possible to replace pre-defined 'Query Params' with enabling 'Propagate Query Params'. If set, the query params passed with the request to Artifactory, will be passed on to the remote repo.
Please note, according to JFrog docs, this setting is only available for Generic type repositories.
I was able to make it work on Windows using the following:
I created a generic remote repository, making sure it is pointing to https://download.cypress.io, and under the advanced tab, added the query params: platform=win32&arch=x64 (notice there is a dedicated field for it).
The above is required in order to cache the correct binary based on the OS and arch (you might require a different remote repository with different query params).
I found it on Cypress doc that these query params control the binary type which will be downloaded (so we need to make sure it fits the client os and arch).
In the .npmrc I simply provided the following:
CYPRESS_DOWNLOAD_MIRROR=https://user:myverystrongpassword#myartifactory/artifactory/generic-cypress-windows
I've used this command (on MacOS) to directly pass path to downloaded Cypress.zip file
CYPRESS_INSTALL_BINARY=~/Downloads/cypress.zip yarn add cypress --D

Yarn - There appears to be trouble with your network connection. Retrying

I have been trying to do the quickstart guide for react native, but kept getting this error
There appears to be trouble with your network connection. Retrying...
My connection works just fine.
This happens when your network is too slow or the package being installed is too large, and Yarn just assumes it's a network problem.
Try increasing Yarn network timeout:
yarn add <yourPackage> --network-timeout 100000
Deleting the yarn.lock file and rerunning "yarn install" worked for me.
I got this issue because I was working within my company internal network and proxy needed to be set.
$ yarn config set proxy http://my_company_proxy_url:port
$ yarn config set https-proxy http://localhost:3128
example $ yarn config set https-proxy http://proxy.abc.com:8080
Simple working solution (right way of doing it):
Looks like yarn was trying to connect via a proxy. The following worked for me:
npm config rm proxy
npm config rm https-proxy
Source
Turning off "real time protection" with windows defender fixed it for me.
Sucks but it appears the checks are too much for yarn to handle.
Could be that your network speed is too slow and timeout is relatively short, you can set yarn install --network-timeout=30000
If you still have the error, could be solved by proxy, vim ~/.yarnrc and add useful proxy setting.
yarn config set network-timeout 600000 -g
Often, your error is caused by hitting the network connection time limit, and yarn simply reports there is "trouble with your network connection".
The line of code at the top of my answer sets the global yarn network timeout to 10 minutes.
Having a long network timeout is probably okay, because yarn uses caches and if it's big and you don't have it, you probably want it to just go ahead and take the time to download.
Could be a proxy issue. Run the command below to delete the proxy.
yarn config delete proxy
The following helped me
yarn config delete https-proxy
yarn config delete proxy
they set your https-proxy and proxy values to undefined. My https-proxy was set to localhost. Check that proxy and https-proxy config values are undefined by using the following
yarn config get https-proxy
yarn config get proxy
The large package involved often can be Material Design Icons.
Check if you make use of the Material Design Fonts material-design-icons in your package.json and remove it!
material-design-icons is too big to handle and you should only use material-design-icons-fonts if you only need them.
https://medium.com/#henkjan_47362/just-a-short-notice-for-whomever-is-searching-for-hours-like-i-did-a741d0cd167b
Turn off or disable your antivirus before run this command. I am also facing same issue than i disable quick heal antivirus and it is works.
create-react-app my-app
When I want to use yarn I have above error, but there is not any error with npm, for this situation you can install react project from npm
npx create-react-app app --use-npm
Deleting the yarn-lock file, doing a yarn cache clean and then a yarn solved my issue
npm install
worked for me (but my project was built with yarn)
Got the exact issue when trying yarn install
yarn install --network-timeout 100000
Just using this didn't solve my problem. I had to install only ~5 packages at a time. So I ran yarn install multiple times with only few dependencies in the package.json at a time.
Hope this helpful
In short, this is caused when yarn is having network problems and is unable to reach the registry. This can be for any number of reasons, but in all cases, the error is the same, so you might need to try a bunch of different solutions.
Reason 1: Outdated Proxy Settings
This will throw the "network connection" error if you are connected to a network that uses a proxy and you did not update yarn configs with the correct proxy setting.
You can start running the below commands to check what the current proxy configs are set to:
yarn config get https-proxy
yarn config get proxy
If the proxy URLs returned are not what you expect, you just need to run the following commands to set the correct ones:
yarn config set https-proxy <proxy-url>
yarn config set proxy <proxy-url>
Similarly, if you have previously set up the proxy on yarn but are no longer using a network connection that needs a proxy. In this case, you just need to do the opposite and delete the proxy config:
yarn config delete https-proxy
yarn config delete proxy
Reason 2: Incorrect Domain name resolution
This will throw the "network connection" error if for whatever reason your machine cannot resolve your yarn registry URL to the correct IP-address. This would usually only happen if you (or your organization) are using an in-house package registry and the ip-address to the registry changes.
In this case, the issue is not with yarn but rather with your machine. You can solve this by updating your hosts file (for mac users, this should be found in '/etc/hosts') with the correct values, by adding a mapping as follows:
<ip-address> <registry-base-url>
example:
10.0.0.1 artifactory.my.fancy.organiza.co.za
Adding option --network=host was the solution in my case.
docker build --network=host --progress=plain .
I encountered this error while attempting yarn outdated. In my case, a few of the packages in my project were hosted in a private registry within the company network. I didn't realize my VPN was disconnected so it was initially confusing to see the error message whilst I was still able to browse the web.
It becomes quite obvious for those patient enough to wait out all five retry attempts. I, however, ctrl-c'd after three attempts... 😒
In my case I found a reference to a defunct registry in my ~/.yarnrc file
When I removed that the error went away
This happened in my case trying to run yarn install.
My project is a set of many sub-projects.
After a couple of retries, it showed a socket-timeout error log:
error An unexpected error occurred: "https://<myregitry>/directory/-/subProject1-1.0.2.tgz: ESOCKETTIMEDOUT".
I cloned subProject1 separately, did yarn install on it and linked it with main project.
I was able to continue with my command on main project after that.
Once done, I unlinked the subProject1 and did a final yarn install --force which was success.
I got this error while trying to run yarn install - i use WSL with ubuntu distro, the following command fixed it,
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null
This may be a late answer but here are some possible reasons:
If you are behind a proxy you may need to configure .npmrc if you are using npm or .yarnrc if you are using yarn
If proxy is well setup, you may need remove yarn.lock or package-lock.json and re-run npm i or yarn
If you are working within a docker environment or elsewhere that might need a different approach where you are not modifying the installation process, try adding a file named .yarnrc in the root of the project with the problem (where your package.json resides) and in that file write:
network-timeout 600000
Docker will still run without modifying the docker-compose.yml file and you get the timeout solution.
I faced the same issue but adding VS Code to the Firewall Exception List has solved my issue.
I got the same issue but my case is totally different. I am on Linux, and I get this error because I had a service nginx status off.

How to exclude certain domains from an npm proxy

We use npm behind a company firewall and thus use proxy and https-proxy settings in the npm configuration. This works fine as long as all npm modules are loaded from an external registry. But as a matter of fact we also have internal modules on an internal github. The access to these modules must not use the proxy of course. My question is: Can I specify a list of domains in the npm configuration, for which the proxy should not be used? Something like the no_proxy environment variable in the unix shell?
Assuming your environment looks like this:
Build server with internet access only over proxy: your.proxy.host:3128
Local Nexus Registry: https://your.local.nexus.registry/nexus/content/groups/npm/
NPM must use local Nexus Registry. Configuration file: .npmrc
registry = https://your.local.nexus.registry/nexus/content/groups/npm/
You can tell npm to use a proxy by setting the environment variables
http_proxy=http://your.proxy.host:3128
https_proxy=http://your.proxy.host:3128
but then npm will also try to reach your (local) Nexus Registry using the proxy.
You need to have one of the latest npm Versions (npm 2.14.7 works fine) and set an additional environment variable to exclude your Nexus Registry from the proxy:
no_proxy=your.local.nexus.registry
Since NPM 6.4.1, released on 2018-08-22, you can use the noproxy option, even with a custom registry configured.
Example :
npm config set registry "http://<my-npm-registry-host>:<registry-port>"
npm config set proxy "http://<my-proxy-host>:<proxy-port>"
npm config set https-proxy "http://<my-proxy-host>:<proxy-port>"
npm config set noproxy "my-proxy-host" (accepts pattern like *.domain)
Check config :
npm config list
References :
NPM doc for noproxy
NPM changelog
NPM PR #46
to exclude certain domains , you can add below lines in .npmrc
noproxy[]=.local.nexus
noproxy[]=.internal.npm.repo
https://docs.npmjs.com/misc/config#noproxy
As adiesner indicated, you cannot set a noproxy/no_proxy in the npm config, so the only way to do this is via the environment variables:
npm config set registry "your.local.nexus.registry/nexus/content/groups/npm/"
export http_proxy="http://your.proxy.host:3128"
export https_proxy=$http_proxy
export no_proxy="your.local.nexus.registry"
If you are using cntlm you should configure the NoProxy option in the configuration file "/etc/cntlm.conf". For instance,
Username your_user
Domain UCI.CU
Password your_password
Proxy 10.0.0.1:8080
Listen 3128
NoProxy uci.cu, edu.cu, nexus.prod.uci.cu, localhost, 127.0.0.*, 10.*, 192.168.*
Remember that you must restart cntlm: sudo systemctl restart cntlm
For PowerShell, the commands are:
$Env:http_proxy = "http://your.proxy.host:3128"
$Env:https_proxy = "http://your.proxy.host:3128"
$Env:no_proxy = "..."

Not able to connect to atom.io for themes and packages

I believe my work proxy is preventing me from being able to add themes and packages to Atom. From the preferences menu, I get:
Fetching featured packages and themes failed. Hide output…
tunneling socket could not be established, cause=140499728967552:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:766:
Is it possible to make it use my $https_proxy variable? Is there some way to configure it to not use https?
You can configure your proxy settings in ~/.atom/.apmrc (or Atom\resources\app\apm\node_modules\atom-package-manager\.apmrc in Windows). Per the apm README:
If you are using a proxy you can configure apm to use it by setting the https-proxy config in your ~/.atom/.apmrc file like so:
https-proxy = https://9.0.2.1:0
It seems that as of Atom 1.0, there are some components that respect the http-proxy and https-proxy variables, and others that don't. For example, the initial check for the version of Atom works, but the check for packages doesn't seem to respect the http-proxy or https-proxy settings.
I was able to get Atom working with Fiddler as my proxy (on 127.0.0.1:8888) by running the following commands (on Windows):
apm config set proxy http://127.0.0.1:8888
apm config set strict-ssl false
I did not need to set http-proxy or https-proxy. I don't know if these settings have been deprecated or not, but they don't seem to work reliably in 1.0. The setting proxy works (and upgrades itself to TLS 1.2 automatically).
The entirety of my %USERPROFILE%\.atom\.apmrc file is:
strict-ssl=false
proxy=http://127.0.0.1:8888/
I was getting this error on Windows 7 fro Atom 1.0, when trying to look up packages.
In my case the issue was resolved by setting https-proxy variable to use http protocole instead of https. so both of the following parameters have exact same value.
here are the values from ~.atom.apmrc file
proxy=http://[host]:[port]/
https-proxy=http://[host]:[port]/
the answer by #NYCdotNet below that suggested to use
strict-ssl=false
didn't work as i was able to lookup some packages but installation failed with timeout error from GIT.
Atom will use your shell's proxy variables (like $https_proxy) if you start Atom from a shell that has these variables set. You need to have the Atom command line tools installed for that to work.
From a shell, you can simply type atom to open the editor for the current directory. It will use all environment variables from this shell, including the proxy variables.
I find this a lot easier than setting the variables in the config file.
I edited the ~/.atom/.apmrc file to set my proxy as mentioned by #AlexMooney, but still got errors.
The solution was to write
proxy = http://host:port
strict-ssl = false
in that ~/.atom/.apmrc file.
For Windows you can easily configure the https-proxy via command line:
amd config set https-proxy https://9.0.2.1:0
It should be stored under C:\Users\...\.apm in file .apmrc
See userconfig with command
amd config list
To config Proxy for Atom to install new pakage, just open CMD and run these commands:
apm config set strict-ssl false
apm config set proxy your_proxy
apm config set your_proxy
I am working behind a proxy server and spent about half a day on this issue, setting https_proxy as well as http_proxy didn't make a difference.
What did it for me was setting the proxy from the cmd line like so:
apm config set proxy http://myproxyaddress:port
I still can't install packages through Atom's gui, but doing it through the cmd line works fine. That I'll take.
I later realised I could've switched to the wifi and got it to work immediately...

Resources