一个包中有多个package.json文件 [英] Multiple package.json files in one package

查看:286
本文介绍了一个包中有多个package.json文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行在php上的站点,该站点使用Node来完成一些开发任务。当前,我们的团队依靠puppet来安装用于这些开发任务的节点模块,但是,我正在考虑改为在网站根目录中使用package.json文件。

I have a site running on php that uses Node for a few development tasks. Currently, our team relies on puppet to install the node modules that we use for these development tasks, however, I was thinking of moving to using a package.json file in the root of the site instead.

我的问题是:

我的php应用实际上是3个单独的站点,我们将它们混合成一个站点(1个面向公众的站点,1个内部站点,即1个面向客户的网站),并且该应用的某些安装可能依赖于不同的节点程序包(或同一pacakge的不同版本)。虽然我知道将这些应用程序分开并让每个应用程序管理自己的依赖关系会很好,但除此之外,是否可以通过某种方式在一个站点中包含多个package.json文件?

My php app is actually 3 separate sites that we have mixed into one (1 public facing site, 1 internal site, 1 client facing site) and its a likely scenario that some installations of the app depend on different node packages (or different versions of the same pacakge). While I know it would be nice to split these apps apart and have each one manage its own dependencies, short of this, is there some way to have multiple package.json files in one site?

换句话说:

/package.json
/site1/package.json
/site2/package.json
/site3/package.json

或者有没有办法让一个package.json处理多个应用程序的依赖项?

Or perhaps, is there a way to have the one package.json handle dependencies for more than one app?

我不知道这是否有意义,请告诉我是否就在这里左字段的出口。谢谢!

I don't know if this makes sense, let me know if I'm just way out in left field here. Thanks!

推荐答案

据我所知,package.json处理单个目录的依赖项(以及单个node_modules实例) )。

As far as I have seen, package.json deals with a single directory's dependencies (and a single instance of node_modules).

最好的选择是将应用程序拆分到单独的目录中。

Your best bet is to split your applications into separate directories.

除非如此,将所有依赖项添加到单个package.json文件中。它将安装到node_modules文件夹中,该目录中的任何应用程序都可以访问所有已安装的模块。

Barring that, you could just add all of the dependencies to a single package.json file. It will install into the node_modules folder and any app within that directory will have access to all of the installed modules.

这篇关于一个包中有多个package.json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆