npmjs.com

Private, scoped modules

Lots of companies using Node.js love the "many small modules" pattern that is part of the Node culture. However, splitting internal applications and private code up into small modules has been inconvenient, requiring git dependencies or other workarounds to avoid publishing sensitive code to the public registry. npm On-Site makes private modules a first-class citizen.

npm On-Site requires a 2.x+ version of the npm client. You can get this by running

[sudo] npm install npm -g

Once you have an up-to-date client, log in to your registry using your GitHub or GitHub Enterprise credentials:

npm login --registry=http://myreg.mycompany.com:8080 --scope=@myco

Now you can install private modules without any additional work, the same way you do with public modules:

npm install @myco/somepackage

npm automatically knows that any package with the @myco scope should be installed from your npm On-Site installation. Scoped packages will be installed into your node_modules folder and can be used in your JavaScript just like any other module:

require('@myco/somepackage');

Publishing private modules is similarly easy. Simply give your package name a scope in package.json:

{
  "name": "@myco/anypackage"
}

Then publish as usual:

npm publish

npm will automatically publish to your npm On-Site, and will refuse to publish scoped packages to the public registry.

Last modified November 29, 2015           Found a typo? Send a pull request!

Getting Started

How npm works

Private Modules

Organizations

Using npm

npm On-Site

CLI Commands

Configuring npm

npm policy documents

View All On One Page