How to Publish NPM Packages

Exploring the publishing process to the public npm registry

Scoped and Unscoped Packages Explained

Setting up an NPM Package

npm login#fill out username, password and email address prompts
npm whoami
node -v
npm -v

Setting npm defaults

npm config list --json
"init-author-name": "",
"init-author-email": "",
"init-author-url": "",
npm set "Ross Bulat"
npm set ""
npm set ""

Explore npm with the help command

# get all npm commands on offer
npm --help
# detailed documentation on particular command usage
npm help <command>
# shortened list of sub-command usage
npm <command> --help

Publish under your username or under an Org?

Setting up a Package

mkdir mypackage
cd mypackage
git init
git remote add <remote_url>
npm init# fill out details or leave blank if they do not apply
# scope package under my username
npm init --scope "@rossbulat"
# or scope package under an Org
npm init --scope "@jkrb"

Ready to publish? — Not yet

Choosing a version

Choosing a Licence

/* Copyright 2017-2019 @polkadot/apps authors & contributors
/* This software may be modified and distributed under the terms
/* of the Apache-2.0 license. See the LICENSE file for details. */

Readme file

Add badges to your README using Travis CI

Other Considerations

.npmignore with .gitignore

Before Publishing: Test the package

npm install . -g

Publishing and Updating Packages

npm publish

Updating with npm version

# major bump. E.g. 1.0.0 to 2.0.0 
# %s here being the version number
npm version major -m "major release v%s"
# or minor bump. E.g. 1.0.0 to 1.1.0
npm version minor
# or patch bump. E.g. 1.0.0 to 1.0.1
npm version patch -m "bug fixes"
# publish
npm publish
git add .
git commit -m "new release"
git tag v1.1.0
git push origin master --tags
npm version from-git
npm publish

Where to go from here?

Programmer and Author. Director @ Creator of for iOS.

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