Puddinq.com sharing knowledge

Creating an npm package

Creating an npm package

I have enjoyed the easiness of npm packages a lot, they give you quick tools to do what they are specified for. I was so enthusiastic I wanted to make my own. Knowing it would be a lifetime study I am creating this post to document the basics and eventually more specific want to haves.

1 The start

You need to make a little software package and publish it. To be able to publish it you need an npmjs account.

1.1 Create a npmjs account

1.2 Login to your account on the commandline

$ npm login

2 Create the files

The only thing really required is a package.json, and only a name and version field is the required content of that file.

2.1 Manually create a file

Create a file called package.json in the folder (root) where you will be creating the package:

  "name": "@puddinq/puddinq-cli",
  "version": "1.0.0"

2.2 Automatically create a file

You can let npm create the file for you. It will ask for more details than the minimal required one, but for a project that actually does something it saves some tome.

$ npm init