Private NPM is here. Congratulations to the NPM team for shipping it!
NPM just announced the long-awaited support for private modules – you can try them today!
Setup
First you have sign up here. After setting it up, you are good to go.
Next thing is to make sure you npm login
with the account you just upgraded.
Creating Your First Private NPM Module
After you are done with the previous tasks, it is pretty much the same as before: you can create your module using npm init
– the only thing you have to pay attention to is the naming convention of your package. All private packages are scoped, which is your username. So to create one you have to enter @usernam/package-name
as the name of the module:
gergelyke ~/Development/risingstack/test-private $ npm init This utility will walk you through creating a package.json file. It only covers the most common items and tries to guess sane defaults. See <code>npm help json
for definitive documentation on these fields and exactly what they do. Usenpm install <pkg> --save
afterward to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (test-private) @risingstack/test-private version: (1.0.0) description: entry point: (index.js) test command: git repository: keywords: author: license: (ISC) About to write to /Users/gergelyke/Development/risingstack/test-private/package.json: { "name": "@risingstack/test-private", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "author": "", "license": "ISC" }
You are all set, it is time to implement your module! If you need a tutorial on how to get started doing that, I encourage you to read our Publishing your first Browserify/Node module
Publishing
Same as always – npm publish
.
Access Control
You add readonly and read/write access to contributors using either the CLI or the NPM website. With access control we arrive to a currently missing functionality: organizations are not supported for now, but they are on the roadmap.
Outro
Should you start using it today? If your team is small, then yes. If you are managing a bigger engineering team then currently it is not for you – you should wait for the organization support.