Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the main key in package.json mandatory?

I have a repo which contains a collection of a few Node.js serverless, Function-as-a-Service functions. The functions share the same node_modules directory, but deployed separately to our FaaS platform.

npm init creates a "main": "function.js" entry in package.json. Since I don't have a single (or any) entry point, I wonder if I can remove this line altogether.

Is the main key in package.json mandatory?

like image 966
Adam Matan Avatar asked Oct 31 '18 12:10

Adam Matan


Video Answer


1 Answers

No, it's not mandatory.

You can publish a package on npm (using the npm publish command) even without specifying a main entry point. So you're free to remove it from your package.json.

According to the docs, the only required fields are "name" and "version".

like image 129
Simone Avatar answered Oct 04 '22 06:10

Simone