Hello developers, If you want to use Yarn over NPM in your project and you are wondering how to authenticate Yarn using .npmrc file then post is going to help you especially when you are depending on private npm packages repository like Nexus.
Since you are using your private npm packages then you might have already setup your registery in .npmrc file like below:
//urlToMyNexus/repo/npm-public/:_authToken=NpmToken.242a389a-a92e-3187-8256-50e71e05c51b
Now you want to install all packages over the set up group repository in nexus via yarn install
. The .yarnrc in home home dictionary is empty.
Problem:
When you run yarn install
command, it should able to install all @angular packages in the dependencies now, but it fails at rxjs unfortunately and it gives the error error Couldn't find package "rxjs" on the "npm" registry.
If you try npm install
with the same configuration all packages are installed correctly over the nexus repository. So where is the issue now? Well the problem is that Yarn is not able to authenticate over the private npm package repository which is Nexus in this case.
Solution:
To handle this issue you have to follow the steps mentioned below:
yarn config delete registry
to delete current registry url from yarn inner config.always-auth=true
in your existing .npmrc file. So the .npmrc file should looks like this://urlToMyNexus/repo/npm-public/:_authToken=NpmToken.242a389a-a92e-3187-8256-50e71e05c51b
always-auth=true
After completing above steps run yarn install
in your project directory path and you'll notice that all the projet dependancy have installed successfully.
I hope you have liked this post. Let me know if you still find any difficult by commenting below. I would love to help you. Also if you think this post has helped then let me know your opinion and don't forget to share this post with other developers.
See you in the next blog post. So keeping rocking!
Related post: Yarn vs. NPM: Unleashing the Power of Package Managers for Efficient JavaScript Development
No comments:
Post a Comment