How to specify local registry in yarn?

我只是一个虾纸丫 提交于 2020-06-11 17:36:18

问题


I have a local nexus server, I'd like yarn to look through it before going online, basically prefer-offline

yarn install --prefer-offline --cache-folder C:\folder\yarn-cache --preferred-cache-folder C:\folder\yarn-cache --non-interactive --no-lockfile --registry http://server/repository/npm-group

Yarn fails to find a dependency offline then fails to go online. I don't know if that can be fixed.


回答1:


  • Create an npm (hosted) repository to use as your private registry. I believe you have already done this.
  • Create an npm (proxy) repository pointing to your external repository of choice (https://registry.yarnpkg.com or https://registry.npmjs.org/).
  • Create an npm (group) with your private registry on first position and the proxy registry on second position.
  • Point yarn to your group repository: yarn config set registry http://nexus.local/repository/npm-group/. If required by your Nexus configuration, authenticate yarn: yarn login.

Also be wary of yarn using any npm config you might have over it's own: https://github.com/yarnpkg/yarn/issues/4862




回答2:


You can set a different registry in yarn by using the following command:

yarn config set registry <url-to-your-registry>

Verify that it has been set by typing the following command:

yarn config get registry

For a one-off change in registry you can use the variable YARN_REGISTRY like this:

YARN_REGISTRY="<url-to-your-registry>" yarn config get registry

or

YARN_REGISTRY="<url-to-your-registry>" yarn publish


来源:https://stackoverflow.com/questions/49898859/how-to-specify-local-registry-in-yarn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!