Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge multiple (npm) package.json files into one with Gulp?

Lets assume I have a mainFolder and 3 subfolders (subFolderA, subfolderB, subfolderC).

And these subfolders all contain a package.json with dependencies and devDependencies. (mainFolder/subFolderA/package.json)

I want to combine them into a single package.json in mainFolder (mainFolder/package.json)

Is there an existing gulp package (or any other solution outside Gulp) to combine and merge package.json dependencies and devDependencies?

(Let's assume there will be no version conflict. If there is a solution also covers that case, thats great!)

Can you post an example gulpfile.js or explain other ways/tools.

Thank you

like image 394
Murat Ozgul Avatar asked Jun 09 '16 19:06

Murat Ozgul


1 Answers

You can try package-json-merge npm module. To install it, use this command -

npm install -g package-json-merge

Then simply use below command to combine multiple package.json into a single one -

package-json-merge package1.json package2.json .... packageN.json > package.json

like image 69
Lokesh Jain Avatar answered Nov 16 '22 02:11

Lokesh Jain