Closed ckitterl closed 3 years ago
+1 here.
yarn config set registry
doesn't have any effect on 1.3.2. Though it works as expected on 1.2.1. Had to downgrade.
@ckitterl @Wain-PC I've dug into this issue and it could be that .yarnrc
or .npmrc
is overriding the config. Can you share what the rc files + lockfile look like?
I've deleted the yarn.lock
and it solved the problem. Packages are downloaded from my private registry.
$yarn --version
1.3.2
Reference: https://github.com/yarnpkg/yarn/issues/2508#issuecomment-283655600
It not work @thibault-p.
I made a clear workspace at /tmp/test/
, and initialized a npm package named test. The test directory just contains a file named package.json. After that I wrote a private dependency manually and ran yarn install
. Unfortunately I got an yarn error, because yarn could not recognize the registry config.
~/.yarnrc
registry "http://registry.npm.personal/"
lastUpdateCheck 1511786203577
"registry=http://registry.npm.personal/" true
~/.npmrc
registry=https://registry.npm.taobao.org
regls=
The workspace file list
Total 44
drwxrwxr-x 2 mk mk 4096 11 27 20:59 .
drwxrwxrwt 25 root root 28672 11 27 20:58 ..
-rw-rw-r-- 1 mk mk 260 11 27 20:36 package.json
-rw-rw-r-- 1 mk mk 3046 11 27 20:59 yarn-error.log
yarn-error.log file content
Yarn version:
1.2.0
Node version:
6.7.0
Platform:
linux x64
npm manifest:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"@sdp.nd/nd-react-wrapper": ""
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
yarn manifest:
No manifest
Lockfile:
No lockfile
Trace:
Error: https://registry.npm.taobao.org/@sdp.nd%2fnd-react-wrapper: Not found
at Request.params.callback [as _callback] (/usr/share/yarn/lib/cli.js:61949:18)
at Request.self.callback (/usr/share/yarn/lib/cli.js:122920:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/usr/share/yarn/lib/cli.js:123903:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/usr/share/yarn/lib/cli.js:123823:12)
at IncomingMessage.g (events.js:291:16)
at emitNone (events.js:91:20)
@kaylieEB
"registry=http://registry.npm.personal/" true
is caused by the command
yarn config set registry=http://registry.npm.personal/
Using the key=value
syntax when setting a config is not supported (from what I can tell) in yarn. However, this is still supported as of version npm 5.6, albeit undocumented since it is a legacy syntax. See https://github.com/npm/npm/blob/v5.6.0/lib/config.js#L139-L147
Be sure you're setting your configs in yarn using (without the =
!)
yarn config set <key> <value>
e.g.:
yarn config set registry "http://registry.npm.personal/"
@ckitterl IIRC, npm config takes priority over yarn config, so you'd have to remove registry=https://registry.npm.taobao.org
in .npmrc or point it to your personal registry.
@zamnuts It's not work yet
Do you mean I can not set registry of yarn that different from npm?
npm config takes priority over yarn config
Hi, this is relative to only .npmrc
, I tried this by setting NPM_CONFIG_REGISTRY
(env var), and npm takes it, but not yarn 😕
It should, we even use it in the tests:
https://github.com/yarnpkg/yarn/blob/master/packages/pkg-tests/yarn.test.js#L43
@arcanis I'm getting a sort of an inconsistent behavior compared to NPM. In this case the env var doesn't take effect for Yarn - I ensured that there's no registry previously set from .yarnrc
.
gbort@gbort-mbp:~$ npm config get registry
https://martifactory.io/api/npm/virtual-npm/
gbort@gbort-mbp:~$ NPM_CONFIG_REGISTRY=https://example.com/npm/registry npm config get registry
https://example.com/npm/registry
gbort@gbort-mbp:~$ yarn config get registry
https://registry.yarnpkg.com
gbort@gbort-mbp:~$ NPM_CONFIG_REGISTRY=https://example.com/npm/registry yarn config get registry
https://registry.yarnpkg.com
gbort@gbort-mbp:~$ yarn --version
1.10.1
hey hey i encountered the same issue here, by just grepping through the sources i found a variable called YARN_REGISTRY which works.
$ yarn config get registry
https://registry.yarnpkg.com
$ NPM_CONFIG_REGISTRY="http:test" yarn config get registry
https://registry.yarnpkg.com
$ YARN_REGISTRY="http:test" yarn config get registry
http:test
but i actually do not know if this is a supported way or does only work by accident as i couldn't find the documentation for this.
i have set yarn registry config to my own private repo using "yarn config set registry https://myrepo/" but when "yarn install" finished.. i check yarn lock file and it points to default yarn registry... not mine.... i had to use --registry option in order to use my own registry.... any ideas???
The reason for not taking effect is caused by .npmrc ...
just:
vim ~/.npmrc
//registry=https://registry.npm.taobao.org
registry=http://myPrivateRegistry
show this:
successfully!
Uninstalled yarn by
sudo apt remove cmdtest
It worked for me
On mac, I created a .yarnrc
with the following:
registry "https://abc.xyz.com"
and it worked
hmmm?
$ cat ~/.yarnrc
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
this might help, try yarn add some-module --verbose
to check the output.
I have yarn 1.19.1 installed, found it also reads npmrc files and it ignores the yarnrc if there is ~/.npmrc
(for me i was a logged user for private npm registry so this file contains token) there.
Same issue here, this time, for specific registry setup not global. seems to be different on windows maybe slightly different the .yarnrc gets populated with the wrong format if you skip the quotes
yarn config set "@myown:registry" "http://myserver:4323"
will make yarn: "@myown:registry" "http://myserver:4323" to keep the npm sane the format is more like: (you can edit manually the .npmrc "@myown:registry"="http://myserver:4323"
without the quotes it gets the aforementioned wrong formatsomething=true
I've removed everything in "C:\Users\User\AppData\Local\Yarn\Cache" and "C:\Users\User\AppData\Local\Yarn\Data\global", and now its working...
yarn config set registry=http://localhost:8080
yarn config v1.22.4
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/config for documentation about this command.
Closing as we've fixed all config-related issues in v2 where we only support .yarnrc.yml
as the single source of truth.
Also don't forget to regenerate yarn.lock file after changing registry. It's neccessary because yarn.lock contains links to old registry
Do you want to request a feature or report a bug? bug
What is the current behavior?
I used "yarn config set registry http://myPrivateRegistry" to config a custom registry.But it's not work, and be rewrited by npm config. There is a custom registry at npm
After config yarn registry, I checked
When I used yarn to install $MyPrivatePackage, yarn retrieved from http://registry.npm.taobao.org and failed.
Please mention your node.js, yarn and operating system version.