Edit: this only applies to npm versions <1.0
It was hard to figure it out, but NPM makes it possible .
You need three components
- Subdirectory in your repository (i.e.
deps/ ) - The
package.json file in the above directory listing the dependencies - The
index.js file in the above directory, which requires your dependencies
Example
Imagine express is your only addiction
Deps / package.json
Note. Increase version # each time the dependency changes
{ "name": "myapp_dependencies", "version": "0.0.1", "engines": { "node": "0.4.1" }, "dependencies":{ "express": "2.0.0beta2" } }
Deps / index.js
export.modules = { express: require('express')
Now you can install your dependencies using npm. You can even do this part of the deployment process.
cd deps npm install
Then, in the application code, you can access your specific version of the expression as follows:
var express = require('myapp_dependencies').express;
Daniel Beardsley Mar 13 2018-11-11T00: 00Z
source share