My pckage.json looks like this:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
...
How does it know where to find the index.js
file? What if I have multiple index.js files in different directories?
CodePudding user response:
TL;DR: The main
property is static, not relative.
The index.js is relative to the package root, or the package.json
. If you have this.
.
├── package.json
├── index.js
└── utils.js
Then it will point to ./index.js
, as it is relative. If you have a index.js
in src/index.js
, the main
will need to point to src/index.js
instead.