Alex Rivera | Logout

Use an alternate dependency list for Node.JS + NPM

Asked 2011-12-12T18:10:05.967
10

Is it possible to have two package.json files for a single NodeJS project?

In a project I'm working on, there is an optional and experimental feature which requires some node packages of its own. For every day development, I do not want to force all developers to install those packages.

What I'd like, essentially, is a file which just lists npm dependencies in the a similar format as package.json, and then use npm install to install all of them.

eg:

// package.json:
{
    "dependencies": {
        "underscore": "1.1.7",
        "connect": "1.7.0"
    }
}

// alt.json
{
    "dependencies": {
        "experimental_package": "0.0.1",
        "and_another_one": "1.33.7"
    }
}

And then, something like:

$ npm install
// install the regular package.json stuff
$ npm install alt.json
// install the other ones

Please note that this is not the same as devDependencies

Edit
Report

1 Answer

3

You could make a small script (even in Node.js) so that it executes 'npm install .' twice: one for the original package.json and then for alt.json (package.json gets renamed to _package.json and alt.json gets renamed to package.json; after that's finished rename the files as they were).

I'm not sure about this I've never tried, but I think it could work.

answered 2011-12-12T18:39:05.457

Your Answer