The idea of NodeJS is to use NPM (Node Package Manager) to install everything. That will generate a node_modules folder containing all packages installed with NPM.
package.json is like a setup.py + a requirements.txt in Python, or a manifest.xml file in other languages. That means it holds informations like the project name, the running version, a description, and dependencies.
The purpose of dependencies from this file is that running npm install Will install them all in a node_modules folder inside the current project.
Therefore when using git, you may consider adding /node_modules/ to your project .gitignore file and still preserve dependencies.
Open the package.json file and add dependencies manually, then run npm install
But an easier way is let NPM do it all.
mkdir myproject cd myproject npm init
npm init will prompt you with a few suggestions and build a package.json file automatically
npm install express --save
Will install expressJS to the node_modules folder AND thanks to the --save option will also add it to your dependencies in the package.json file.
npm uninstall express --save
Will uninstall expressJS and clean it out of packages.json.
List all installed package with
I you have tip to share, just tweet me.
By vinyll on Dec. 21, 2012