I started using lerna to be able to install all node modules for all sub packages using a single command.
At the moment I do not use any other lerna features except lerna bootstrap
.
My lerna.json
:
{ "lerna": "3.22.0", "npmClient": "yarn", "packages": [ "package-a", "package-b" ], "version": "1.0.0" }
my root package.json
:
{ "name": "test", "private": true, "version": "1.0.0", "scripts": { "postinstall": "lerna bootstrap" }, "dependencies": { "lerna": "^3.22.1" } }
my package-a
‘s package.json
:
{ "name": "package-a", "version": "1.0.0", "private": true, "dependencies": { "moment": "2.22.0" } }
my package-b
‘s package.json
:
{ "name": "package-b", "version": "1.0.0", "private": true, "dependencies": { "package-a": "1.0.0", "moment": "2.22.0" } }
i want to upgrade moment
in the package-b
.
if i run yarn upgrade moment --latest
in the package-b
folder i got the following error:
yarn upgrade v1.22.5 [1/4] 🔍 Resolving packages... error Received malformed response from registry for "package-a". The registry may be down. info Visit https://yarnpkg.com/en/docs/cli/upgrade for documentation about this command.
if i run npx lerna --scope package-b exec -- "yarn upgrade moment --latest"
in the root folder i get the following error:
lerna notice cli v3.22.1 lerna notice filter including "package-b" lerna info filter [ 'package-b' ] lerna info Executing command in 1 package: "yarn upgrade moment --latest" yarn upgrade v1.22.5 [1/4] 🔍 Resolving packages... error Received malformed response from registry for "package-a". The registry may be down. info Visit https://yarnpkg.com/en/docs/cli/upgrade for documentation about this command. lerna ERR! yarn upgrade moment --latest exited 1 in 'package-b' lerna ERR! yarn upgrade moment --latest exited 1 in 'package-b'
How should I properly upgrade node module in the lerna’s sub-package?
Advertisement
Answer
Because both of your packages are private the npm
repository can’t find them during the upgrade of the moment
library. Also the lerna
package is currently largely unmaintained.
There exists a workaround. Temporally delete the "package-a": "1.0.0",
line from your package-b.json
file.
Updated package-b/package.json
file:
{ "name": "package-b", "version": "1.0.0", "private": true, "dependencies": { "moment": "2.22.0" } }
Now run:
cd package-b && yarn upgrade moment --latest && cd ..
Then put the "package-a": "1.0.0",
line back to your package-b.json
file.