I am in the process of switching my monorepo (back) from yarn (with workspaces) to lerna/npm, because yarn is too slow and unstable. However, I made an surprising discovery. With the following trivial package.json
:
{
"devDependencies": { "lerna": "^2.11.0" },
"dependencies": { "typescript": "^2.9.1" }
}
and an empty lerna.json
(in other words, no packages at all), then when I run
$ lerna bootstrap
it does not install anything at all in any top-level node_modules
directory. And if for some reason I have a node_modules
directory with no .bin
subdirectory, then lerna bootstrap
fails to create or populate the .bin
subdirectory.
Is lerna not designed to actually specify top-level packages which are to be installed (along with their binaries in .bin
)? I do notice that if I try lerna add
on a lerna monorepo with no packages, it complains that "lerna WARN No packages found in scope where tslint can be added."
I could not find anything related to this in the documentation. With yarn/workspaces, I was using the ability to install global (top-level) versions of things like TypeScript for use in my build scripts while maintaining control over the version installed.
From the Lerna docs:
You can add the root as a managed location (in the packages array of
lerna.json
) - if that's something you need. This would cause lerna to link root's dependencies to your packages' directories, runpostinstall
script along with the others, etc.