Using the Package.js (using a Package.json)
The best way to manage the local NPM package is to create a package.js file. The package.json file contains a lot of stuff.
- He is a document that describes the packages that you have included in your project
- Contains the version of the package used in your project
- Better porting of projects (better to share your project with other developers)
Parameters that must be included
As a minimal package.js file, Package.js should include:
"Name"
- All lowercase
- There is no space between words
- Allow dashes and underscores to be used
"Version"
For example:
"Name": "My-awesome-package""version": "1.0.0"}
Create a package.js (Creating a Package.json)
Use the npm init command to create a Package.json file.
NPM Init
This command launches a command line "problem" that will create a package.js file in the directory of your project.
Add a--yes tag after Init
The extensibility issues that run on NPM init above are not for everyone. If you want to use your package.js more flexibly, you still need these extensibility issues.
You can add the --yes or the-y tag after npm init to create a default package.js
NPM Init--yes
The above command creates a default Package.js file, and many of the problems are default values that are filled in. As follows:
- "Name": In the case of a git file directory in the project is the GIT repository name, the default is the name of the package you want to create
- "Version": Default is 1.0.0
- "Version": Always a Index.js
- "Scripts": An empty test script is created by default
- "keywords": Empty
- "Author": Can be any name
- "License": ISC
- "Repository": if yes, that's GitHub's code warehouse for this package.
- "Bugs": contains some bug issues such as some issue submitted on GitHub
- "Homepage": Your This package on GitHub's home address
You can also configure some other things in the NPM init command, as follows:
> NPM Set init.author.email "[email protected]" > NPM set Init.author.name "Ag_dubs" > NPM set init.license "MIT"
NPM package.js Guide