Skip to content

zaenk/nexus3-npm-repo-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Set up Nexus with Docker

  • 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 packages
    • npm-3rdparty, hosted, for not public 3rd party packages
    • npm-npmjs, proxy, https://registry.npmjs.org
    • npm-public, group, for the 3 above
      • URL will be sth like: http://192.168.99.100:8081/repository/npm-public/
  • in Nexus Administration > Security > Realms add npm bearer Security Token Realm

Set up npm locally

  • 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
  • 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

Test repository

  • 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

Related Guides

About

Testing Nexus 3 with private npm repository

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published