Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Configuring NPM to use the CEDAR Nexus Server

Martin O'Connor edited this page Aug 24, 2017 · 21 revisions

CEDAR artifacts are hosted on BMIR's Nexus server.

A user called cedar that has administrative access on this server. The password is in the CEDAR password stash.

Nexus can be configured to act as an NPM repo and an NPM proxy.

Follow the instructions here to create an NPM proxy called npmjs, a private CEDAR NPM registry called npm-cedar, and a CEDAR group called npm-cedar-all.

After generating these create an .npmrc file with the following content (note the Nexus password that should be replaced with a real password) and place it in your home directory.

; .npmrc configured to use BMIR's Nexus server
;
; BMIR Nexus server has proxy called npmjs, a private repo called npm-cedar, and a group called npm-cedar-all
; Configured per: https://books.sonatype.com/nexus-book/3.0/reference/npm.html

; CEDAR NPM registry group
registry=https://nexus.bmir.stanford.edu/repository/npm-cedar-all/

; CEDAR NPM registry
; TODO @org.metadatacenter:registry=https://nexus.bmir.stanford.edu/repository/npm-cedar/
registry=https://nexus.bmir.stanford.edu/repository/npm-cedar/

; base64 encoded authentication token
; To generate: echo -n 'cedar:<NEXUS PASSWORD>' | openssl base64
_auth=XXXXXXXXXXXXXXXXXXXXXX

; Force auth to be used for GET requests
always-auth = true

; We don't want to put certificates in .npmrc
strict-ssl = false

; To publish a JavaScript artifact to the npm-cedar repository put the following in the project root:
;
; "publishConfig" : {
;   "registry" : "https://nexus.bmir.stanford.edu/repository/npm-cedar/"
; }

; An email is required to publish npm packages
[email protected]

; This information is used when publishing
init.author.name = CEDAR
init.author.email = [email protected]
init.author.url = https://metadatacenter.org/

To reflect these settings for the CEDAR NPM registry do the following:

npm login --registry=https://nexus.bmir.stanford.edu/repository/npm-cedar/

You may first need to configure Nexus to support NPM bearer token authentication. To do this go to the Administration->Realms item and add npm Bearer Token Realm.

We also want to use org.metadatacenter as the scope for the CEDAR registory:

npm 

If you want to modify and update these settings you must first log out as follows:

npm logout

To publish a JavaScript artifact to the npm-cedar repo put the following in the package.json file in the root of the JavasScript project:

"publishConfig" : {
   "registry" : "https://nexus.bmir.stanford.edu/repository/npm-cedar/"
}

Then a standard npm publish command should publish the artifact.

Clone this wiki locally