Is this the package.json file used by node?

The package.json file used by node when starting the application, or is it used only for npm to install dependencies?

What I really need to know is: when I launch the application using

node myapp

Is the package.json file read or ignored?

+6
source share
2 answers

package.json actually used by node itself. Here is the code: https://github.com/joyent/node/blob/master/lib/module.js#L101 Basically, when you require in a directory, it checks to see if the directory has package.json , and if it uses the file from him main .

otherwise package.json used only in npm , but nothing stops you from reading it in your code.

+6
source

Of course he reads package.json! You can define the starting point of the application (file) that will be called when you enter node "appName".

To determine this and other parameters (dependencies..etc), type: npm init and follow the console wizard.

You can check out this guide: http://package.json.nodejitsu.com/

+1
source

All Articles