Share npm devDependencies accross modules


(Stephen) #1

I have a number of modules that use the same devDependencies and I would like to make those dependencies a module itself, or some other way to manage them centrally. Are there any established patterns for achieving this?

I’ve looked in to using npm scripts to install the dev dependencies in the parent module, however it does feel a bit hacky e.g.

module-x has a dev dependency on module-shared-dev-dependencies. module-shared-dev-dependencies has a postinstall script that changes the cwd to module-x and npm install --save-dev eslint prettier husky … etc. It then copies over the relevant config info such as rc files. Modules like husky currently only have the config info in the package.json file itself, so that would need modified too.

There is also the potential to have a base module in the git that all other modules fork from, however, I’d rather stick to an npm module approach if possible.


(Lars Willighagen) #2

You can look into lerna, it may not be exactly what you’re looking for but perhaps it works good enough in independent mode.


(system) #3

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.