Display the issue of adding dependencies that breaks the ability to remove them later on.
IMPORTANT: This is applicable to npm
and yarn
. To switch to yarn
, add npmClient: yarn
to lerna.json.
Tested with npm
7.0.3 and npm 6.14.8. Tested with yarn
1.22.10.
npm ci
to install the specific Lerna version at the time of the issue. (v3.22.1).npx lerna bootstrap
.npx lerna add my-package-not-in-the-registry --scope=first
.- Results:
- A
node_modules
folder will be created withinfirst
folder. It will contain a symlink tomy-package-not-in-the-registry
local folder. - No
package-json.lock
will be generated. my-package-not-in-the-registry
will added to thefirst
package.json.
- A
- Results:
- Add a dev dependency e.g:
nodemon
.npx lerna add nodemon --dev --scope=first
.- Results:
nodemon
is added topackage.json
underdevDependencies
- A
package-json.lock
is created, including a../my-package-not-in-the-registry
local reference.
- Add a regular dependency e.g:
isomoprhic-unfetch
.npx lerna add isormoprhic-unfetch --scope=first
.- Results:
isomorphic-unfetch
is added topackage.json
underdependencies
.nodemon
andmy-package-not-in-the-registry
remain underdependencies
anddevDependencies
respectively inpackage.json
.- ISSUE: My
../my-package-not-in-the-registry
reference is removed frompackage-json.lock
.
- Attempt to add/remove any depedency:
npx lerna exec "npm uninstall nodemon" --scope=first
- ISSUE: The command will fail because the reference to
my-package-not-in-the-registry
is missing and it is not available in the public registry. - IMPORTANT: If the name/version of the local package does match the registry, the
remove
command will succeed, but the wrong package reference will be saved topackage-json.lock
.
SOLUTION: Manually remove package-json.lock
, run an add/remove command. E.g: npx lerna exec "npm uninstall nodemon" --scope=first
.
To retry the steps:
npx lerna clean
remove allnode_modules
. When asked, submity
.- Remove all
package-json.lock
oryarn.lock
files inpackages
. They aregitignored
for the purposed of this example. - Remove all changes to
package.json
dependencies. E.g:git checkout .
nodemon
and isomorphic-unfetch
are examples. I was able to replicate the issue with other packages, and in different order.