Setup of npm package storage – In this tutorial you will learn:
1.How to install npm on ubuntu
2.Basic usage commands for npm and storage using Nexus Sonatype
Prerequisites
Before you begin, you will need the following requirements:
- An Ubuntu 22.04 server.
- A non-root user with sudo/administrator enabled.
- A domain name pointed to your Ubuntu server IP address (For production)
- Have a proper internet connection
- Have a proper setup of Sonatype-nexus server
Before installing any package, run the apt command below to
update and refresh your repositories package index.
$sudo apt update
![Setup of npm package storage](https://devopslover.com/wp-content/uploads/2023/08/image-28.png)
To install npm on Ubuntu
$ sudo apt install npm
OR
$ sudo apt install npm nodejs
![](https://devopslover.com/wp-content/uploads/2023/08/image-29.png)
Basic usage commands for npm
Here’s a list of the various npm commands you’ll likely need to know:
To see the version of npm and verify it’s installed on the system:
$ npm –version
![](https://devopslover.com/wp-content/uploads/2023/08/image-30.png)
$ node –version
![](https://devopslover.com/wp-content/uploads/2023/08/image-31.png)
Once it installed successfully.. You can use below steps for publishing npm packages on nexus server
>Most important thing make sure you have to done set your ip address first. Using if config , ip address , or ip a commands
Lets get start it Actual sonatype nexus setup for npm storage
1. How to create your own npm repository on Sonatype-Nexus server
Open Your Sonatype-Nexus Server using your ip and port And login into it
![](https://devopslover.com/wp-content/uploads/2023/08/image-32.png)
![](https://devopslover.com/wp-content/uploads/2023/08/image-33.png)
Open repository menu and click on create repository. You need to create your own npm repositoy for publishing your npm-packages..
click on npm(hosted)
![](https://devopslover.com/wp-content/uploads/2023/08/image-34.png)
Using below reference create your npm repository
![](https://devopslover.com/wp-content/uploads/2023/08/image-35.png)
And click on create repository at last…
Once is done open realms menu on Sonatype-nexus Server transfer your npm Bearer Token Realm to right side
![](https://devopslover.com/wp-content/uploads/2023/08/image-36.png)
![](https://devopslover.com/wp-content/uploads/2023/08/image-37.png)
And click on save button
once you create your own repository copy your repo url for log in purpose..
Open your Terminal (ctrl + alt + T)
![](https://devopslover.com/wp-content/uploads/2023/08/image-38.png)
First you need to set your proxy setting… use below steps for do it.
npm config set proxy http://(Your ip and port) npm config set https-proxy http://(Your ip and port) npm config set registry (your-nexus-url-paste-here) npm login
npm notice Log in on your-nexus-url
Username: Your-nexus-username
Password: Your-nexus-password
Email: (this IS public) (Your-email-address)
Logged in as Your-nexus-username on your-nexus-url
If You have followed above steops as one by one you will get success to login npm repository
If is it done then please do belove steps for exploring to it..
Then you need to create git repository.. and git clone in to it
![](https://devopslover.com/wp-content/uploads/2023/08/image-39.png)
$ git clone https://Your-git-repository
once it create and cloned successfully … need to set your credentials into it
![](https://devopslover.com/wp-content/uploads/2023/08/image-40.png)
I have cloned my repository successfully.. and varified it.
$cd npm-registry-couchapp
![](https://devopslover.com/wp-content/uploads/2023/08/image-41.png)
$npm publish
![](https://devopslover.com/wp-content/uploads/2023/08/image-42.png)
Varify it using your created repositoy on Sonatype-Nexus server
![](https://devopslover.com/wp-content/uploads/2023/08/image-43.png)
Hope you like this blog….
- Sending slack notification via pipeline job - August 25, 2024
- SonarQube integration with Jenkins - August 24, 2024
- Deployment of 2 application java and python using k8s : slack alerting Using Jenkins pipeline liberary - August 10, 2024