How to have main file in sub directory

So in node.js I have my main file in subdirectory ‘src/’
Is there any way I can make the package.json link to that src/index.js

Yes, adding this to your package.json will do that:

"main": "src/index.js",