A generic definition of package.json
could be:
All npm packages contain a file, usually in the project root, called package.json - this file holds various metadata relevant to the project. This file is used to give information to npm that allows it to identify the project as well as handle the project's dependencies. It can also contain other metadata such as a project description, the version of the project in a particular distribution, license information, even configuration data - all of which can be vital to both npm and to the end users of the package. The package.json file is normally located at the root directory of a Node.js project.
Running npm init
on the working directory of the project that you want to distribute as an npm package, will guide you, through a command-line wizard, to creating the package.json
file, through some questions (i.e. description of your project, contributors, etc.).
dependencies
are other projects, required to run the specified project as an end user, whereas devDependencies
, are the ones required to also develop the project. Here is a more detailed answer, according to all kinds of dependencies.
main
The main field is a module ID that is the primary entry point to your program. That is, if your package is named foo, and a user installs it, and then does require("foo")
, then your main module's exports object will be returned.
scripts
You can think of scripts
as an object which exposes additional npm
commands. The object assumes that the key is the npm
command and the value is the script path.
For instance, according to your case, when running npm test
the console will display Error: no test specified
and will then exit.
For more information, you can read the full documentation and/or have a look at this interactive guide.