Setup of npm package storage on Linux 22.04 using Nexus Sonatype

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:

  1. An Ubuntu 22.04 server.
  2. A non-root user with sudo/administrator enabled.
  3. A domain name pointed to your Ubuntu server IP address (For production)
  4. Have a proper internet connection
  5. 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
To install npm on Ubuntu

$ sudo apt install npm

OR

$ sudo apt install npm nodejs

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

$ node –version

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

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)

Using below reference create your npm repository

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

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)

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

$ git clone https://Your-git-repository

once it create and cloned successfully … need to set your credentials into it

I have cloned my repository successfully.. and varified it.

$cd npm-registry-couchapp
$npm publish

Varify it using your created repositoy on Sonatype-Nexus server

Hope you like this blog….

Mahesh Wabale

Leave a Comment