instruction |
Description |
Example |
Name |
The unique name of the package |
"Name": "Camelot" |
Preferglobal |
Indicates that the module is more likely to be installed at the global scope |
"Preferglobal": True |
Version |
The version of the module |
"Version": 0.0.1 |
Author |
Author of the Project |
"Author": "[email protected]" |
Description |
Text description of the module (description) |
"description": "A small feature" |
Contributors |
Other contributors to the module |
"Contributors": [ "Name": "Zhang San", "Email": "[email protected]" ] |
Bin |
Binary files installed with the project |
"Bin": { "Excalibur": "./bin/excalibur" } |
Scripts |
Start node is the parameter "scripts" that executes the console application |
"Scripts": { "Start": "Node./bin/excalibur", "Test": "Echo Testing" } |
Main |
The main entry point of the application, which can be a binary or. js file |
"Main": "./bin/excalibur" |
Repository |
Repository type and location of package |
"Repository": { "Type": "Git", "Location": "Http://xxx.com/c.git" } |
Keywords |
Keywords that appear in NPM search |
"keywords": ["AAA", "BBB"] |
Dependencice |
This module relies on modules and versions that you can use * and X wildcard characters |
"Dependencies": { "Express": "Latest", "Connect": "2.x.x", "Cookies": "*" } |
Engies |
The version of node that this package can use |
"Engies": {"node": ">=0.6"} |
The advantage of using the Package.json file is that dependencies are automatically downloaded and installed for your node. JS application. You only need to create a Package.json file in the root directory and add the necessary dependencies.
For example, the following Package.json file requires the Express module as a dependent module:
{
"Name": "My_module",
"Version": "0.1.0",
"Dependencies": {
"Express": "Latest"
}
}
Then, run the following command from the root directory of the package, and the Express module will automatically install:
NPM Install
Note that NPM install does not specify any modules. This is because NPM will find the Package.json file by default. If you need additional modules later, you only need to modify the Package.json file, add the required modules to the dependent instructions, rerun the NPM install
Instructions used in the "node. JS Learning Note Eight" Package.json file