How to Deploy an NPM Package
Filip Podstawski
Publishing your first package to npm is straightforward. Here's a minimal path from zero to published.
Prerequisites
- Node.js (v18+)
- An npm account
Steps
-
Log in to npm (once per machine):
npm loginUse your npm username, password, and email.
-
Prepare
package.json- Set a unique name (e.g.
@your-scope/your-packageoryour-package). - Set version (e.g.
1.0.0). - Ensure main (or exports) points to your entry file.
- Set a unique name (e.g.
-
Publish
npm publishFor a scoped package (e.g.
@myorg/foo), make it public on first publish:npm publish --access public -
Later updates
Bump version (e.g.
npm version patch) then runnpm publishagain.
That's it. Your package will be available at https://www.npmjs.com/package/your-package.
Want to know more? Contact us via email.
contact@surdic.com