Hi guys, nice to see you again. Today I am gonna explain you about metadata inside package.json.
The package.json is used as what equates to a manifest in applications, modules, packages and it is used to make modern development streamlined, modular, and efficient. Let us look at the contents inside the package.json.
When giving the name property we have to consider some restrictions as, max length of 214 characters, cannot begin with . or <i> , no uppercase letters, no characters that arenot URL friendly.
The package.json is used as what equates to a manifest in applications, modules, packages and it is used to make modern development streamlined, modular, and efficient. Let us look at the contents inside the package.json.
The name property
The name property in a package.json file is one of the important componenets of the package.json file. name is a string that you would expect as the name of the module.When giving the name property we have to consider some restrictions as, max length of 214 characters, cannot begin with . or <i> , no uppercase letters, no characters that arenot URL friendly.
The version property
This property denotes the current version of the version of the module that the package.json file is describing.
The license property
This property denotes the license of the version that the package.json file is describing.Some examples for license are, MIT, ISC, GPL-3.0.
The description property
This property is a human readable description about the module.The description property is frequently indexed by serach tools like npm search, npm CLI to find relavant packages based on the search query.
The keyword property
This property is a collection of keywords on the module and it is an array with one or more strings as the array values.
Functional metadata inside package.json
The main property
This property is a direction to the entry point of the module.
The repository property
This property defines an array where the source code for the module lives.As an example if the source code location is git hub, then the URL mentioned under repository property should be the location of the source code.
The dependencies property
This property defines all the other modules that this module uses (dependencies) - are defined. Note that you will find carets (^) and tildes (~) included with package versions.
The devDependencies property
Although the dependencies property is used to define the dependencies that the module needs to run in production, the devDependencies property is usually used to define the dependencies the module needs to run in development.
Good bye
Next let us look at how to specify dependencies and devDependencies in package.json file.
You can add dependencies to package.json file from the command line or by manually editing the file.
Adding dependencies to the package.json from the command line.
To add an entry to the "dependencies" attribute of the package.json file, the command is given below.
npm install <package-name> --save-prod
To add an entry to the "devDependencies" attribute of the package.json file, the command is given below.
npm install <package-name> --save-dev
Adding dependencies can also be done manually instead of using commands.
That is all for today,
Hope to see you with another blog post soon,
Till then,Good bye
Comments
Post a Comment