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 config set registry" is not work #4862

Closed
ckitterl opened this issue Nov 6, 2017 · 23 comments
Closed

"yarn config set registry" is not work #4862

ckitterl opened this issue Nov 6, 2017 · 23 comments
Assignees
Labels
fixed-in-modern This issue has been fixed / implemented in Yarn 2+. triaged

Comments

@ckitterl
Copy link

ckitterl commented Nov 6, 2017

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

$ npm config get registry
http://registry.npm.taobao.org

After config yarn registry, I checked

$yarn config get registry
http://myPrivateRegistry/

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.

$yarn --version
1.2.0
$npm --version 
5.3.0
@ghost ghost assigned arcanis Nov 6, 2017
@ghost ghost added the triaged label Nov 6, 2017
@Wain-PC
Copy link

Wain-PC commented Nov 7, 2017

+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.

@kaylie-alexa
Copy link
Member

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

@thibault-p
Copy link

I've deleted the yarn.lock and it solved the problem. Packages are downloaded from my private registry.

$yarn --version
1.3.2

Reference: #2508 (comment)

@ckitterl
Copy link
Author

ckitterl commented Nov 27, 2017

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

@zamnuts
Copy link

zamnuts commented Feb 9, 2018

"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/"

@kaylie-alexa
Copy link
Member

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

@ckitterl
Copy link
Author

ckitterl commented Mar 7, 2018

@zamnuts It's not work yet

@ckitterl
Copy link
Author

ckitterl commented Mar 7, 2018

Do you mean I can not set registry of yarn that different from npm?

@gerardobort
Copy link

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 😕

@arcanis
Copy link
Member

arcanis commented Oct 22, 2018

It should, we even use it in the tests:

https://github.com/yarnpkg/yarn/blob/master/packages/pkg-tests/yarn.test.js#L43

@gerardobort
Copy link

@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

@jreusch-barco
Copy link

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.

@wildergd
Copy link

wildergd commented Mar 6, 2019

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???

@godkun
Copy link

godkun commented Mar 22, 2019

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!

@agnelvishal
Copy link

Uninstalled yarn by
sudo apt remove cmdtest
It worked for me

@526avijitgupta
Copy link

On mac, I created a .yarnrc with the following:

registry "https://abc.xyz.com"

and it worked

@jreusch-barco
Copy link

jreusch-barco commented Jan 21, 2020

hmmm?

$ cat ~/.yarnrc 
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

@zoubingwu
Copy link

zoubingwu commented Jan 25, 2020

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.

@kapekost
Copy link

kapekost commented Feb 27, 2020

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 format something=true

@SeyyedKhandon
Copy link

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...

@ghost
Copy link

ghost commented Aug 31, 2020

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.

@paul-soporan
Copy link
Member

Closing as we've fixed all config-related issues in v2 where we only support .yarnrc.yml as the single source of truth.

https://yarnpkg.com/getting-started/migration

@bass1387
Copy link

Also don't forget to regenerate yarn.lock file after changing registry. It's neccessary because yarn.lock contains links to old registry

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-modern This issue has been fixed / implemented in Yarn 2+. triaged
Projects
None yet
Development

No branches or pull requests