Is package.json file used by node when the application starts or is it used only by the npm for installing dependencies?
What I really need to know is this: when I start the app using
node myapp
Is the package.json file read or ignored?
Is package.json file used by node when the application starts or is it used only by the npm for installing dependencies?
What I really need to know is this: when I start the app using
Is the package.json file read or ignored?
package.json
is actually used by node itself. Here is the code: https://github.com/joyent/node/blob/master/lib/module.js#L101 Basically, when you require
a directory, it checks if the directory has package.json
and if does uses file from it's main
property.
otherwise package.json
is used only in npm
, but nothings stops you from reading it in your code.
Of course it reads package.json ! You can define your application starting point (file) that will be called when you type node "appName".
To define that and other parameters (dependencies..etc) type : npm init and follow the console wizard.
You can check this guide : http://package.json.nodejitsu.com/