Search code examples
javascriptdependenciesmonorepocl

Dependencies vs devDependencies in monorepo


This cl tool can be installed as a devDependency. But they say to install it as a dependency if you are in a monorepo.

Why is that?


Solution

  • devDependencies in the root package.json can be used in all packages in the monorepo. This is generally used to co-locate test-related deps and config (jest, eslint, etc).

    A couple caveats:

    1. This only works for non-CLI devDependencies. If you need to run a CLI from a child package, that CLI needs to be in that package's devDependencies. (transpiling, flowcopy, etc)
    2. All dependencies for a given child package still need to be listed in that child's package.json. (obvious, perhaps? just clarifying)

    Source: https://github.com/lerna/lerna/issues/1079#issuecomment-337660289