Introduction
Are you a software developer? Have you started to use npm and are curious what package.json file is?
If you’re a bit intimidated by the command line when using npm, don’t be; you only need to know when to use it and how to use it properly.
Another thing to point out, if you think that there are many configurations needed to start your project, my advice is to start with the minimum configuration and build from there.
That’s why this article focuses on the package.json file, npm init and npm install, and then you can play and experiment further.
What is a Package.json File?
The package.json file represents various metadata relevant to the project. Moreover, it helps npm identify the project’s information and dependencies, and it typically resides at the root directory of a project.
Therefore, a package.json's primary purpose is to hold and represent the various metadata and configurations related to the project.
In simple terms, it is a manifest file that describes your project or application.
When is it recommended to have and not to use the package.json file?
It is highly recommended and necessary to have a package.json file:
- If you want to create a public package (if you don’t know what a package is? we’ll see it in the next section)
- If you are working with a team
Finally, it is not recommended or necessary to have a package.json file:
- If you’re experimenting or working alone with a website or web application and don’t need to share it outside of your local computer, you don’t need to have a package.json file
- If you aren’t going to use npm or yarn as your package manager
What’s a package?
A package comprises JavaScript’s one or more modules and a package.json file representing the package’s metadata.
Let’s see an example of a package below.

As you can see in this example, we have an Axios package installed in our project.
Once installed, a node_modules directory is going to be created for packages to reside.
By listing the package’s directories and files, you’ll see that this package also has a package.json file and its modules reside inside the lib directory.
What’s Inside the Package.json file?
Let’s take a look at what’s inside the package.json file.





Reinhard SchmidlinPosted Jun 27, 2022, 4:48 PM
I have this problem while doing npm install.