Gobliins Gobliins - 1 year ago 102
Node.js Question

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

So i start off with writing my own node.js app and the only thing i want is to include a package for saml.

So i was wondering what is the minimal requirement for my app.

I was just creating a node.js file and then i installed the package by:

node install some-saml-passports-package

I got this warning after installation:

npm WARN enoent ENOENT: no such file or directory, open '.../mynodeapp/package.json'

I remved the package and created a package.json file. Which results in a parsing error because there was no content inside.

I have read that i only need a package.json when i plan to create my own package. also i read something about local and global installation of package files in npm. Well, i need a bit of clarification for my doing.

What is the use of package.json?

Do i need it when i only want to create a standalone app in node with one dependency to an existing package?

Is it recommended even if i dont need it at all?

Answer Source

There is no minimum requirement for node.js application package.json is only require to manage your application like for dependencies, module descriptions , handle npm scripts etc. you can install packages without package.json just don't have --save flag with npm install eg:

npm install <package_name>, you can still run your node application without any problem. But i will suggest you 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 do npm init in your project root directory and answer some basic questions in console.

here are some usefull links:

npm init

how to use package.json

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download