Database Reference
In-Depth Information
the
package.json
file has been created, dependencies such as
async
can
be added by adding a
dependencies
section:
{
"name": "myproject",
"version": "1.0.0",
"description": "My first node.js project",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": "",
"author": "Byron Ellis",
"license": "BSD",
"dependencies":{
"async":"*"
}
}
To install the dependencies, simply execute
npm install
to get the latest
version (because
“*”
was specified in the preceding code instead of a
specific version number):
$ npm install
npm WARN package.json myproject@1.0.0 No README.md
file found!
npm http GET https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/async
async@0.2.9 node_modules/async
Another way of doing this is to install the async package with npm and use
the
save
option:
$npm install async --save
This automatically updates the
dependencies
section of
package.json
with an appropriate entry for the module of interest.
After development has started, it is usually best practice to fix the version
of any dependency to avoid bugs introduced by changes to those packages.