Tuomas Toivonen
Tuomas Toivonen

Reputation: 23472

Uploading node_modules to Nexus hosted NPM repository

We are building our project in offline build server. Thus we have to store and maintain all our project dependencies in local network Nexus.

I have created hosted NPM registry in Nexus following this guide. I skipped the proxy and group part. Now I want to upload (and maintain) all the project NPM packages (node_modules) from my local workstation to this repository. I don't see upload button in the Nexus repository settings. How to properly upload and maintain NPM packages in Nexus NPM registry? Can this be done by the Nexus GUI, or do I have to use command line? Note the nexus is disconnected from the internet.

Upvotes: 0

Views: 3753

Answers (3)

Darker
Darker

Reputation: 11

You don't need to upload the node_modules.

You need to create a proxy and a group repository.

Then you can delete the node_modules and package-lock.json in your project and run npm install.

Because your hosted don't have those packages,it will download them from proxy.

Then you can see those packages in the group.

When you run npm install again,it will download form Nexus ,not NPM.

The download speed will be very fast.

Upvotes: 1

Jorge
Jorge

Reputation: 137

The UI does not handle transitive dependencies.

You can also use the rest API to manage components directly, and upload all your .tgz packages.

POST ​/v1​/components

For instance, to upload the package my-npm-package-0.0.0.tgz to the repository npm-private use the following:

curl -u user:password -X POST "http://localhost:8081/service/rest/v1/components?repository=npm-private" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "[email protected];type=application/x-compressed"

The complete live API specs can be found at endpoint /#admin/system/api

The official nexus documentation can be found at https://help.sonatype.com/repomanager3/rest-and-integration-api/components-api

Upvotes: 2

rseddon
rseddon

Reputation: 5320

UI upload for npm packages was added in version 3.7.0.

https://help.sonatype.com/display/NXRM3/Uploading+Components

Upvotes: 1

Related Questions