对节点使用另一个依赖列表。JS + NPM

[英]Use an alternate dependency list for Node.JS + NPM


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

可以要两个包裹吗?单个node . js项目的json文件?

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.

本质上,我想要的是一个文件,它只列出与包类似的格式的npm依赖项。然后使用npm install来安装它们。

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

请注意,这与devDependencies不同

1 个解决方案

#1


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).

您可以制作一个小脚本(甚至是Node.js),这样它就可以执行两次“npm安装”:一次用于原始包。然后是alt.json(包)。json被重命名为_package。json和alt.json被重命名为package.json;完成之后,重命名文件为原样)。

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

我不确定我从来没有尝试过,但我认为它可以工作。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2011/12/12/72011cbebbd84b3ebd9cfa041e3386d1.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告