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

Yarn doesn't use specified registry for yarn install #2508

Closed
7rulnik opened this issue Jan 19, 2017 · 17 comments
Closed

Yarn doesn't use specified registry for yarn install #2508

7rulnik opened this issue Jan 19, 2017 · 17 comments

Comments

@7rulnik
Copy link

7rulnik commented Jan 19, 2017

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When I set npm config set registry my-registry.com npm fetch packages from my-registry.com when I install single module (npm i express) and when I install all modules from package.json (npm i). Yarn goes to my-registry.com only when I type yarn add express, but only for express. All others modules downloaded via yarn registry.

If the current behavior is a bug, please provide the steps to reproduce.

  1. npm config set registry your-registry.com
  2. yarn install --verbose

What is the expected behavior?
Yarn should fetch all modules from specified registry

Please mention your node.js, yarn and operating system version.
node: 7.4.0
yarn: 0.19.1
os: macOS 10.12.2

@robertkowalski
Copy link

Have you tried to set yarns config for the registry?

$ yarn config get registry
# output?

# change with:
$ yarn config set registry your-registry.com

@sharedprophet
Copy link

What I've found is that you have to regenerate or modify your yarn.lock files. They have the full url of each dependency, including the registry it was originally pulled from.

@charmingzuo
Copy link

@sharedprophet it works for me!

@bradydowling
Copy link

Something like this would be a great thing to include in the error message.

@ghost
Copy link

ghost commented Aug 31, 2020

Windows

yarn config set http://localhost:8080

error An unexpected error occurred: "EINVAL: invalid argument, mkdir 'C:\Users\ahmet\http:\localhost:8080'".
info If you think this is a bug, please open a bug report with the information provided in "C:\Users\ahmet\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/help for documentation about this command.

@prodehghan
Copy link

What I've found is that you have to regenerate or modify your yarn.lock files. They have the full url of each dependency, including the registry it was originally pulled from.

How should we regenerate the lock file? Delete and yarn again? Or manually replace all the URLs in "yarn.lock"? Both of these don't look right to me. There should be a command or switch to make yarn update registry URLs in "yarn.lock".

@Dante-dan
Copy link

I can't believe this issue has existed for 4 years.

@WhiteMinds
Copy link

WhiteMinds commented Aug 25, 2021

I can't believe this issue has existed for 4 years.

#3330

@nCore
Copy link

nCore commented Jan 27, 2022

For those who are coming back to this issue:

  1. login with npm to your private registries.
  2. put always-auth=true in your .npmrc locally in the project or globally in your HOME folder at ~/.npmrc
  3. remove yarn.lock (as it might have old registries stored - like https://registry.yarnpkg.com)
  4. do a full install again and re-generate yarn.lock with yarn install

you can always verify if it works with yarn install --verbose and look for your registry instead of default one.

hope it helps - I just fixed my problem and works like a charm with my company's nexus (with authentication).

@Cyber1000
Copy link

Experienced this issue too:

@nCore That's not a full solution to this problem, since deleting your yarn.lock (and recreating) could result in other results (e.g. downloading a version 1.1 instead of 1.0 (or 1.0.5 instead of 1.0.4), depending on how "exact" you set your version (see https://docs.npmjs.com/cli/v8/configuring-npm/package-json#dependencies)
My solution is to just do a replace every registry-occurence within lock.json, even if this feels kind of strange.

@WhiteMinds #3330 was closed in favor of #5892, which was closed too with the comment (#5892 (comment)):

This issue is fixed in Yarn 2+, and the fix will not be backported in 1.x. Please check the Migration guide and continue from there.

Haven't tested in yarn 2 (and also no time), but it seems that this is what we want ("Remove hostnames from the lockfiles"), so maybe this issue will come to an end, since there is no chance for yarn 1.x to get this resolved.

@ahuigo
Copy link

ahuigo commented Apr 14, 2022

For those who are coming back to this issue:

  1. login with npm to your private registries.
  2. put always-auth=true in your .npmrc locally in the project or globally in your HOME folder at ~/.npmrc
  3. remove yarn.lock (as it might have old registries stored - like https://registry.yarnpkg.com)
  4. do a full install again and re-generate yarn.lock with yarn install

you can always verify if it works with yarn install --verbose and look for your registry instead of default one.

hope it helps - I just fixed my problem and works like a charm with my company's nexus (with authentication).

Not work for me.

I had to specify registry in every command: https://stackoverflow.com/questions/55192898/yarn-wont-use-specified-registry

yarn install --registry https://registry.yarnpkg.com/

@rogerprz
Copy link

rogerprz commented Mar 3, 2023

How can I make it fetch from new .npmrc registry changes.

@7rulnik 7rulnik closed this as completed Mar 18, 2023
@yogeshgadge
Copy link

If you are switching registries do yarn cache clean, also delete node_modules

@JustDoItSascha
Copy link

Why is this closed? It doesn't work. And it's not a clean solution to just say "delete the yarn.lock" file. The yarn.lock is there for a purpose. To delete it could harm the integrity of the project. To edit it manually could also produce errors. There should be a mechanism automatically pull the new registry details, maybe with a warning...

@shyn
Copy link

shyn commented Feb 19, 2024

I am shocked that this still not work in 2024.

> yarn --version
1.22.21
> yarn config get registry
http://mirrors.cloud.tencent.com/npm/
>  yarn install --verbose --registry https://mirrors.huaweicloud.com/repository/npm/
[2/4] 🚚  Fetching packages...
verbose 0.388648167 Performing "GET" request to "https://registry.yarnpkg.com/@types/react/-/react-18.2.0.tgz".
(node:90914) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
verbose 0.39729 Performing "GET" request to "https://registry.yarnpkg.com/csstype/-/csstype-3.1.2.tgz".
verbose 0.3983775 Performing "GET" request to "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.16.tgz".
verbose 0.399321375 Performing "GET" request to "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.5.tgz".
verbose 0.400225417 Performing "GET" request to "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.9.tgz".
verbose 0.400992917 Performing "GET" request to "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001561.tgz".

no yarn.lock here and have tried yarn cache clean && rm -rf node_modules

@yordis
Copy link

yordis commented Feb 19, 2024

@shyn, it will never be! Please upgrade the yarn to the latest version; you are using an almost half a decade old Yarn version. https://yarnpkg.com/getting-started/install

huntie added a commit to huntie/react-native that referenced this issue Feb 21, 2024
Summary:
Various fixes/tweaks to the `test-e2e-local` script, impacted by recent changes, found during the release process:

- Fix typo in variable name for `circleciToken` arg.
- Relocate erroneously positioned `process.exit` call (a force exit around Verdaccio, which we will remove in future).
- Add notice on exit around Verdaccio server not being killed successfully (to do in T179377112).
- Switch from Yarn to npm for test project installation — Yarn 3 is not respecting `npmRegistryServer`, see yarnpkg/yarn#2508.

Changelog: [Internal]

Differential Revision: D53951606
huntie added a commit to huntie/react-native that referenced this issue Feb 21, 2024
Summary:
Various fixes/tweaks to the `test-e2e-local` script, impacted by recent changes, found during the release process:

- Fix typo in variable name for `circleciToken` arg.
- Relocate erroneously positioned `process.exit` call (a force exit around Verdaccio, which we will remove in future).
- Add notice on exit around Verdaccio server not being killed successfully (to do in T179377112).
- Switch from Yarn to npm for test project installation — Yarn 3 is not respecting `npmRegistryServer`, see yarnpkg/yarn#2508.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53951606
huntie added a commit to huntie/react-native that referenced this issue Feb 21, 2024
Summary:

Various fixes/tweaks to the `test-e2e-local` script, impacted by recent changes, found during the release process:

- Fix typo in variable name for `circleciToken` arg.
- Relocate erroneously positioned `process.exit` call (a force exit around Verdaccio, which we will remove in future).
- Add notice on exit around Verdaccio server not being killed successfully (to do in T179377112).
- Switch from Yarn to npm for test project installation — Yarn 3 is not respecting `npmRegistryServer`, see yarnpkg/yarn#2508.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53951606
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Feb 21, 2024
Summary:
Pull Request resolved: #43130

Various fixes/tweaks to the `test-e2e-local` script, impacted by recent changes, found during the release process:

- Fix typo in variable name for `circleciToken` arg.
- Relocate erroneously positioned `process.exit` call (a force exit around Verdaccio, which we will remove in future).
- Add notice on exit around Verdaccio server not being killed successfully (to do in T179377112).
- Switch from Yarn to npm for test project installation — Yarn 3 is not respecting `npmRegistryServer`, see yarnpkg/yarn#2508.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53951606

fbshipit-source-id: f6e29ef6c9ab33ebf60124757576fcb54219f339
@Donggggg
Copy link

Donggggg commented Apr 18, 2024

@yordis I'm using version yarn 4.1.1 but it reproduces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests