Node.js Dependency Management with NPM

In addition to the usual git and the rhc command-line tools, you’ll need to install Nodejs as a local development dependency. The npm package manager comes bundled with all recent releases of Nodejs.

Document Your Dependencies

Installing new module dependencies using the --save flag will help keep your project’s package.json file up to date:

$ npm install --save cloud-env
Command line utilities that are usually installed using the -g or --global flag will be automatically be added to the system $PATH, as long as they are included in the dependencies or devDependencies sections of the project’s package.json file.

Local Development

Most Nodejs projects can be initialized by runing npm install followed by npm start.

npm install will attempt to resolve any npm module dependencies that have been declaired in the project’s package.json file, installing them into the node_modules folder.

$ npm install

If the project’s package.json file has been //languages/nodejs/project-structure.html#package.json[configured correctly], running npm start should allow you to start a local webserver:

$ npm start