對節點使用另一個依賴列表。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.

我不確定我從來沒有嘗試過,但我認為它可以工作。


注意!

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



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