node.js minimal setup and for what is the package.json?

There is no minimum requirement for node.js application. The package.json is only required to manage your application for dependencies, module descriptions , handle npm scripts etc. You can install packages without package.json, just don't use the --save flag with npm install. E.g.:

npm install <package_name> - you can still run your node application without any problem. But I will suggest you to add a package.json file and add following:

{
    "name": "<package_name>",
    "version": "<version>", //0.0.1 for starters
    "description": "",
    "main": "<entry point of application>", // example: app.js , index.js etc
    ,
    "author": "<your name>",
    "license": "ISC",
    "dependencies": {}
}

You can create this by adding it manually or just execute npm init in your project root directory and answer some basic questions in console.

Here are some useful links:

npm init

how to use package.json


Create package.json via npm init command. Package.json contains data about your project and what is more important for standalone app - it contains dependencies list. You can install all dependencies from package.json with npm install.

If you want to install package and save it in package.json type npm install package-name --save.


The minimal file is:

{
}

Now you can start using commands like npm install web3 --save and they will save onto this file.