node.jsnexusyarnpkg

How to specify local registry in yarn?


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.


Solution

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

    Update for Yarn v2+:

    Yarn v2+ uses a different configuration key for updating the NPM registry, called npmRegistryServer (see their Migration page for details):

    yarn config set npmRegistryServer http://nexus.local/repository/npm-group/