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.
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.
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.
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.