question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"lerna add" requires package to be present in remote registry (adding unpublished dependencies)

See original GitHub issue

Hello!

Thank you for your hard work.

However, when using lerna add command like this: npx lerna add @acme/button --scope @acme/app it fails with an error: '@acme/button' is not in the npm registry.

I’m trying to add one local unpublished package to the other one.

In order to work around this I have to add the dependency manually to the package.json of the @acme/app package and then run: npm run bootstrap again, which takes some time to process the dependencies.

I think that lerna should be able to effectively add local unpublished dependencies to local packages, which is the point of using the monorepo in the first place.

Probably, the algorithm should be updated to first look for the specified dependency in the local monorepo’s tree, before trying the remote registry.

What do you think?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:30
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

22reactions
madroneropaulocommented, Jun 28, 2020

Still happens in 2020, any update?

9reactions
marcushultmancommented, Sep 10, 2019

We had a similar issue when adding local-package (a new, unpublished package) to some-other-package dependencies. When using npx lerna add local-package packages/some-other-package, local-package also ended up in the root package-lock.json (where some-other-package is declared a dependency using file:packages/some-other-package) causing the error message above.

Package version
lerna 3.16.4
node 12.1.0
npm 6.9.0

To work around it it, first run without bootstrapping: npx lerna add --no-bootstrap local-package some-other-package. Then convert the dependency to a file:-dependency using npx lerna link convert. Now you should be able to run npx lerna bootstrap without it going to the registry for the unpublished dependency.

Adding by relative path (npx lerna add packages/local-package packages/some-other-package) seem to not work at all. By reading source it seems like the AddCommand expects a name from the spec, which is not returned by npm-package-arg for file system local packages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

lerna add on unpublished packages resulting in 404
I was under the assumption that lerna add would add local packages via this method, published or unpublished.
Read more >
@lerna/add | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Bountysource
"lerna add" requires package to be present in remote registry (adding unpublished dependencies)
Read more >
Monorepo using Lerna, Conventional commits, and Github ...
In my case, @xcanchal . Add the repository attribute, with the URL to the Github repository. Add the publishConfig.registry attribute pointing ...
Read more >
package.json - npm Docs
This document is all you need to know about what's required in your package.json file. It must be actual JSON, not just a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found