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!
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!
Share Improve this question asked Jan 9, 2013 at 21:38 gxcgxc 5,1186 gold badges41 silver badges56 bronze badges 2- this need to taken care by deployment time or try docker – Elankeeran Commented Sep 13, 2017 at 14:22
- Check stackoverflow.com/q/50471757 – HelloWorld101 Commented Oct 21, 2020 at 8:32
1 Answer
Reset to default 12As 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.