Why package.json? | npm basics

Shardendu Kumar Gautam
3 min readMar 12, 2018

As a JavaScript developer, understanding the basics of package.json is one of the important pieces that makes your development experience better. So, without further ado let’s dive right into the basics.

Introduction

npm is a package manager for JavaScript with huge listing of reusable code modules and packages. Let’s see what a package manager does:

You have a problem to solve in a project. You address it by writing some code. You start working on another project and face the same problem. So you decide to reuse the code. How would you do that?

Copy and pasting is a not a good way of reusing code as it is neither scalable nor maintainable. Package managers like npm helps in such cases. They let us create/use/version modules that can be reused over and over again.

npm lets us do so much with the help of package.json file.

package.json

This file can contain a lot of meta-data about your project. But mostly it will be used for two things:

  • Managing dependencies of your project
  • Scripts, that helps in generating builds, running tests and other stuff in regards to your project

Creating a package.json file

--

--

Shardendu Kumar Gautam

Cut open my head and you will find nothing but beautiful code… and music.