1

I recently ran npm init -y and noticed this line in package.json:

  "main": "index.js",

Why does npm init -y set this key explicitly set to the default value? Wouldn’t it be cleaner to exclude it and just use the convention of loading index.js?

I want to remove the line from my package.json but I am assuming that npm init -y put it there for a good reason. I have yet to come across such a reason. Please let me know if it included "main" for a reason or if it can be safely deleted.

binki
  • 7,754
  • 5
  • 64
  • 110
  • Possible duplicate of [What is index.js typically used for in node.js projects](https://stackoverflow.com/questions/21063587/what-is-index-js-typically-used-for-in-node-js-projects) – kgangadhar May 28 '18 at 20:09
  • sorry its a typo, it will not cause an error. if you don't want to get into troble, you can use `npm init` which will let you decide your main file. if not after generating `package.json` you have to provide right entry point. – kgangadhar May 28 '18 at 21:07

0 Answers0