NPM package.js Guide

Source: Internet
Author: User

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.

    1. He is a document that describes the packages that you have included in your project
    2. Contains the version of the package used in your project
    3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.