How to install private npm package with yarn?

5.4k views Asked by At

I need to install my company private npm packages with yarn - how do i do it?

I set the npm login auth token but it doesn't help - private npm packages always end up with errors like 404 not found etc.

yarn add @private/my-private-pacakge

doesn't work, but this npm command works:

npm install @private/my-private-package

works - I tried to set yarn config registry/auth with the token but noting helps.

Error:

Error: https://registry.npmjs.org/@private/my-private-package/-/my-private-package-0.0.5.tgz: Request failed "404 Not Found"
      at Request.res (/..../........./.yarn/updates/0.18.1/lib/fetchers/tarball-fetcher.js:231:20)
2

There are 2 answers

2
David On BEST ANSWER

So my problem was with bad configuration I had strict-ssl config to false and registry config to http rather than https.

0
EECOLOR On

For future reference. What worked for me was to create an .npmrc file with the following contents:

//registry.npmjs.org/:_authToken=ACCESS_TOKEN

At first that did not work because the user npm whoami was not added to the team of the organisation (it was the owner of the organisation).

After I added the user to the team the package could be found with npm and yarn.