How To Publish Your Own NPM Module

Share your re-useable code publicly or privately. Making an NPM Module is useful to understand whether you are coding in a corporate environment or just for fun.

Introduction

The Steps to make a Module:

1. Make an NPM Account

2. Log Into NPM Via the NPM CLI

npm login

3. Make an NPM Module

npm init

4. Publish your node module to the registry

npm publish
npm notice 
npm notice 📦 holidaygenerator@1.0.0
npm notice === Tarball Contents ===
npm notice 455B index.js
npm notice 212B package.json
npm notice === Tarball Details ===
npm notice name: holidaygenerator
npm notice version: 1.0.0
npm notice package size: 478 B
npm notice unpacked size: 667 B
npm notice shasum: 1e9b9360199179cbffcd1f095492b17c1d0b9409
npm notice integrity: sha512-YbKgmIvX4cFNc[…]hWro/6voQ2tOg==
npm notice total files: 2
npm notice
+ holidaygenerator@1.0.0

5. Pull your NPM Module down from the registry

node index.js halloween
code: 'MODULE_NOT_FOUND',
npm install --save holidaygenerator
node index.js halloween// returns pumpkin emoji 🎃 as expected
// we've successfully imported the module from npmjs.org

Configuring and Additional Options

1. Move your code to Github

2. Add a License

3. Release Another Version

PUT https://registry.npmjs.org/holidaygenerator - You cannot publish over the previously published versions: 1.0.0.
“version”: “1.2.0”,
npm outdated
npm update

4. scope your package

Pretty cool, huh?

Product Manager + Software Developer. Interested in Travel, Culture, and the Internet.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store