Is Lerna needed anymore with NPM workspaces?

NPM has supported workspaces since version 7, for two major releases now.

With workspaces, npm i / npm ci takes care of nested packages and symlinking. npm run and npm exec can be run across individual or all workspaces:

npm run test --workspace=a --workspace="name-from-package-dot-json"
npm run test --workspaces --if-present

With that said, lerna comes with many more high level features than npm or yarn workspaces.

One great example is the command: lerna changed which gives you the list of packages that have changed since the last tagged release, this could be extremely helpful for CI/CD. you are welcome to explore the extra commands provided by lerna.

I’ve written an article that goes deeper into the configuration in case you want to move to a monorepo with npm7, so working without lerna is definitely an option, you will probably need to do more work on the CI/CD side compared to lerna and add some dev scripts by your self that will affect the nested packages. Also IMO lerna fits more to develop libs rather than apps.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)