Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is package.json file used by node?

Tags:

node.js

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?

like image 279
Dmitri Avatar asked Jan 17 '14 16:01

Dmitri


People also ask

Where is package json in node?

The package. json file is normally located at the root directory of a Node. js project. The name field should explain itself: this is the name of your project.

Is package json required by the node runtime?

Every Node JS application or module or package should contain this package. json file. Every NODE JS project should have this file in the root directory to describe its metadata in plain json object format.

What is the use of package json file?

The package. It is the manifest file of any Node. js project and contains the metadata of the project. The package. json file is the essential part to understand, learn and work with the Node.

Is json same as node JS?

With node. js as backend, the developer can maintain a single codebase for an entire application in javaScript. JSON on the other hand, stands for JavaScript Object Notation. It is a lightweight format for storing and exchanging data.


1 Answers

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.

like image 59
vkurchatkin Avatar answered Oct 06 '22 14:10

vkurchatkin