NPM mirror
Although NPM is used for NodeJS packages rather than operating system ones, I'm including it here as Nexus will happily proxy them as well, improving build times as any downloads are local and not over your internet connection.
Create blob store
Just like for APT we'll create a blobstore just for NPM.
This will be called npm
to follow the same guidelines.
- Log in to Nexus and go to the admin page via the icon in the top nav bar.
- Select blob store, then Create blob store
- Under Type select File
-
Under Name enter
npm
- Select Create blob store to create it.
Create npm mirror
- Log in to Nexus and go to the admin page via the icon in the top nav bar.
- Select Repositories then the Create Repository
-
Select
npm (proxy)
as the repository type. -
Now fill in the required fields.
-
For name enter
npm-proxy
-
For Remote storage enter the repository url
https://registry.npmjs.org
-
For Blob store select the one you created earlier,
npm
if you are following my naming conventions.
-
For name enter
- Once it's all filled in select Save and the Repositories list should now show it.
Create npm group
This is optional. If you are going to just mirror the core npm repository then you can skip this and just
use npm-proxy
directly.
However, Nexus supports grouping multiple repositories together with a group, where if it cannot find an artefact in the first one it would check the next one. This is seamless to the client as all it knows about is there's a single repository.
One use-case for this is if you have a hosted repository where you store your own private artefacts. In this instance you'd create the proxy as above, then an npm-hosted repository. The group would then include both of them as if it's just one.
I'd advise you should create the group with just npm-proxy
present as then your npm
clients will use the group, and you can then seamlessly change the underlying proxies separately.
For example, using an alternate upstream npm repository instead of the default one.
You can do the switch in nexus without changing any client.
- Log in to Nexus and go to the admin page via the icon in the top nav bar.
- Select Repositories then the Create Repository
-
Select
npm (group)
as the repository type. -
Now fill in the required fields:
-
For name enter
npm-group
-
Under member repositories you will see two lists.
On the left hand side select the npm repositories you want to be a member of this group and select
>
. It should then appear on the right hand side.You can change the priority of the entries by selecting the repository name and clicking the up or down arrows. The higher a repository is in the list then they are checked first.
-
For name enter
- Once it's all filled in select Save and the Repositories list should now show it.
Using the mirror
Once you have configured your repositories, you can then now point npm
to use it.
This is described in the Using Repository mirrors section.