Creating a package file
As mentioned when discussing how Node does path lookups, modules may be contained within a folder. If you are developing a program that will work well as a module for someone else to use, you should organize that module within its own folder, and create a package.json
file within that folder.
As we’ve seen throughout the examples in this book, a package.json
file describes a module, usefully documenting the module’s name, version number, dependencies, and so forth. It must exist if you would like to publish your package via npm. In this section, we will outline only a few key properties of this file, and we will also provide more detail on some of the obscure ones.
Note
Try $ npm help json
to fetch detailed documentation for all available package.json fields, or visit: https://docs.npmjs.com/files/package.json.
A package.json
file must conform to the JSON specification. Properties and values must be double-quoted, for example.
Easy init
You can create a package file by...