Knowing package.json fundamentals
The aggregation of multiple modules forms a package. A package is defined by a package.json
file in a directory. This marks the directory as the root of a package. A minimal valid package.json
to indicate a package is as follows:
package.json
{
"name": "my-package",
"version": "1.0.0"
}
Some fields, such as name
or version
, have special meanings. For instance, the name
field is used to give the package a name. Node.js has some rules to decide what is a valid name and what is not.
For now, it is sufficient to know that valid names can be formed with lowercase letters and dashes. Since package names may appear in URLs, a package name is not allowed to contain any non-URL-safe characters.
The version
field has to follow the specification for semantic versioning (semver). The GitHub repository at https://github.com/npm/node-semver contains the Node.js implementation and many...