简体   繁体   中英

Multiple package.json files in one package

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.

My problem is this:

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?

In other words:

/package.json
/site1/package.json
/site2/package.json
/site3/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!

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM