Detailed package.json file

foreword

As the front end develops from multi-page to single-page, from fragmented files to modular development, in a complete project, package.json files are everywhere. First, in the project root directory , and secondly in node _modules. So what exactly does this file do, and what role does it have, I will reveal it to you today.

1. The role of the package.json file

The package.json file is actually a description of the project or module package, which contains a lot of meta information. Such as project name, project version, project execution entry file, project contributors, etc. The npm install command will download all dependent modules based on this file.

2. Create the package.json file

There are two ways to create a package.json file, either manually or automatically.

  • Create manually

    Create a new package.json file directly in the project root directory, and then enter the relevant content.

  • automatically created

    It is also to execute npm init in the root directory of the project, and then enter the corresponding content step by step according to the prompt, and then it can be created automatically.

3. Package.json file example

The post package.json file details first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/8632
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment