giovedì 28 novembre 2013

npm and package.json

npm is official package manager for node.js.
It can be runs throw command line and manages dependencies for an application.
With npm we can install a node.js package hosted on a node.js repository.
In this post i explain a simple package.json file that i wrote to distribute a node.js module (https://github.com/sergioska/noodlejuice).

{

  "name": "noodlejuise",

  "description": "Mini toolkit for node.js",

  "author": "Sergio Sicari <sergiosicari[]gmail.com>",

  "dependencies": {

        "mysql": ">=2.0.0-alpha9",

        "socket.io": ">=0.9.16",

        "node-mysql": ">=0.3.4",

        "csv": ">=0.3.4"

  },

  "directories": {

          "lib": "./lib"

  },

  "repository": {

            "type": "git",

            "url": "git://github.com/sergioska/noodlejuice"

  },

  "engine": "node 0.11.7"

}
In dependencies section there are dependencies module required by own application; in this case mysql, socket.io, node-mysql, csv module.

In repository section there is a link of application repository.

In this way we can install this application only with this package.json file; in a directory that contains this file we run the following command:

npm install


Nessun commento:

Posta un commento