- start docker
docker pull sonatype/nexus3
docker run -d -p 8081:8081 --name nexus sonatype/nexus3
- visit nexus gui
docker-macine ip default
(machine IP, default 192.168.99.100)docker ps
(container port, default 8081)- browse
192.168.99.100:8081
- sing in as admin
- admin, admin123
- create npm repositories
npm-hosted
, hosted, for private packagesnpm-3rdparty
, hosted, for not public 3rd party packagesnpm-npmjs
, proxy, https://registry.npmjs.orgnpm-public
, group, for the 3 above- URL will be sth like:
http://192.168.99.100:8081/repository/npm-public/
- URL will be sth like:
- in Nexus
Administration > Security > Realms
addnpm bearer Security Token Realm
-
mkdir private-hello
-
cd private-hello
-
npm init
- promt everithing
-
add
index.js
exports.hello = funtions(name) { return 'Hello ' + (name ? name : 'world') + '!'; };
-
add mirror (npm-group) URL to
.npmrc
registry = http://192.168.99.100:8081/repository/npm-public/
- you can verify it with
npm config get registry
- you can verify it with
-
add private deployment repository URL (npm-hosted) to
package.json
{ "name": "private-hello", "version": "1.0.0", "description": "", "main": "index.js", "publishConfig": { "registry" : "http://192.168.99.100:8081/repository/npm-hosted/" }, "author": "", "license": "ISC" }
-
set up user with
npm login --registry=http://192.168.99.100:8081/repository/npm-hosted/
, enter nexus credentials -
publish it:
npm publish
-
mkdir test
-
cd test
-
npm init
-
echo "registry = http://192.168.99.100:8081/repository/npm-public/" > .npmrc
-
set up user
npm login
, enter Nexus credentials -
npm install private-hello --save
-
create
index.js
var hello = require('private-hello').hello; console.log(hello()); console.log(hello('Zaenk'));
-
run it:
node index.js