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.

Issue in using workspace: protocol in lerna versioning / publish.

See original GitHub issue

Issue in using workspace: protocol in lerna versioning.

package A has two dependencies in workspace -> package B , C.

when we modify only package A and trigger lerna version or publish, it fails.

Current Behavior

lerna version / publish throws validation error. To use the ‘workspace:’ protocol, ensure that a package with name “${depName}” exists in the current workspace.

Expected Behavior

Lerna version / publish should succeed.

Steps to Reproduce

package A has two dependencies in workspace -> package B , C

modify only package A and try versioning.

Reason

First time, package graph will have all available workspace packages info in its Map. But after lerna tries to write package json and CHANGELOG, the package graph will only have packages to publish info. so it fails.

// File: package-graph/index.js line:60

 Object.keys(graphDependencies).forEach((depName) => {
        const depNode = this.get(depName);
// Here , the depNode will not be available.

Environment

(lerna: 5.5.0 => 5.5.0)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
forehalocommented, Sep 15, 2022

@JamesHenry unfortunately, #3322 did not solve this issue soundly, and I’ve met another issue related to this scenario.

Error says the following line in @lerna/package-graph/index.js didn’t do nullish check(removed in #3322) before using it:


const depNode = this.get(depName);
// L80 C37
// TypeError: Cannot read properties of undefined (reading 'version')
const version = depNode.version;

I’ve created a repo to reproduce it: lerna-version-issue

2reactions
tehKapacommented, Oct 4, 2022

On 5.6.1 the issue remains https://github.com/lerna/lerna/issues/3343

Read more comments on GitHub >

github_iconTop Results From Across the Web

lerna ERR! TypeError: Cannot read property 'version' of ...
We have the same problem. Tested with both lerna version & lerna publish locally and in our bitbucket pipeline. pnpm -v 7.12.2 pnpm...
Read more >
Troubleshooting
This can cause an issue where Lerna will ignore previously published releases which have been manually performed and tagged with the Github web...
Read more >
How to keep workspace:* version specifications when ...
The original Lerna does not currently work properly with workspace: protocol (it will throw some errors and overwrite any workspace: ) ...
Read more >
Why we stopped using Lerna for monorepos
Lerna will keep the workspace: protocol during versioning, which is fine. When publishing, Lerna invokes npm publish with a non-negotiable ...
Read more >
Managing monorepos with Lerna and Yarn workspaces
Lerna and Yarn Workspaces gives us the ability to build and publish libraries and apps in a single repository (a.k.a. Monorepo).
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