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.
As you can see there are two registries defined. The first one is the public registry where we are going to get all open source packages (such as react, moment, etc.) and the second one is our own registry server. Once we have these two files defined, we can install as usual and npm/yarn will resolve correctly.
Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node.
Yarnrc files (named this way because they must be called . yarnrc. yml ) are the one place where you'll be able to configure Yarn's internal settings. While Yarn will automatically find them in the parent directories, they should usually be kept at the root of your project (often your 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
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/
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With