npm, pnpm and Yarn
Set up Yarn
Yarn 2 and later read .yarnrc.yml instead of .npmrc.
.yarnrc.yml
npmRegistryServer: "https://packages.example.com"
npmAuthToken: "${NPM_TOKEN}"
npmAlwaysAuth: true
$ cat .yarnrc.yml nodeLinker: node-modules npmAlwaysAuth: true npmAuthToken: "${NPM_TOKEN}" npmRegistryServer: "https://packages.example.com" $ yarn add react ... ➤ YN0085: │ + react@npm:19.3.0 ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0013: │ A package was added to the project (+ 179.45 KiB). ➤ YN0000: └ Completed ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed ➤ YN0000: · Done in 0s 208ms
Captured by running these commands against a real ForgeRepo™.
Note
Keep npmAlwaysAuth: true. Without it Yarn sends no token for most packages and packages.example.com answers 401.
Yarn 1 (classic) reads .npmrc like npm does, so use the npm setup.