React JS - package.json in Depth

package.json is the most important file in React Application. It contains dependencies and scripts required for the project.

If you see above code of package.json file, it shows :

  • Project Name
  • React Version
  • npm Commands (line no. 14-18)
If we install any third party library, then the dependency will be created inside this file. For Example, you can install React Validation Library by running following command in the terminal :
npm i react-validation
(https://www.npmjs.com/package/react-validation)

Once above library gets installed, you will see dependencies automatically created in package.json file.

We can also edit/change npm default commands in package.json file (line no. 14-18). If we edit any npm command, then we need to run using :
npm run COMMAND NAME

For Example, Instead of npm start command, we want to use, npm run abc, then in Line No. 18, we need to replace "start" with "abc". 

So, now you can compile your project with command : npm run abc.




Comments