Initializing a new npm package

If you want to create a new package, you can create the package.json file by hand or you can get npm's help. The npm init command leads you through a little dialog to get starting values for the package.json file.

Once you get through the questions, the package.json file is written to disk.

Expect to have to edit that file considerably before publishing to the npm repository. A few fields help give a good impression to folks looking at the package listing on npmjs.com:

  • Link to the home page, and issue queue URL
  • Keywords, so it can be linked with other similar packages
  • A good description that helps folks understand the purpose
  • A good README.md file so folks can read some documentation right away

Get Node.js Web Development - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.