lerna / lerna

:dragon: Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
https://lerna.js.org
MIT License
35.64k stars 2.25k forks source link

Lerna seems to not found packages after upgrade #4056

Open dboulardsc opened 1 month ago

dboulardsc commented 1 month ago

Current Behavior

Updated from v7 to v8 with the following config

{
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "version": "1.0.0",
  "npmClient": "yarn"
}

Executing list returns to have found 0 packages. Meanwhile :

Also, seems quite linked to https://github.com/lerna/lerna/issues/4018

Expected Behavior

List the packages my monorepo contains.

Steps to Reproduce

Started a project from scratch and can reproduce the issue.

root package.json :

{
  "private": true,
  "workspaces": [
    "packages/*"
  ],
  "name": "lernatest",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "lerna": "^8.1.7"
  }
}

first package :

{
  "name": "patata",
  "version": "1.0.0",
  "main": "lib/patata.js",
  "scripts": {
    "build": "echo \"build patata\""
  },
  "dependencies": {
    "patato": "1.0.0"
  }
}

second package :

{
  "name": "patato",
  "version": "1.0.0",
  "main": "lib/patato.js",
  "scripts": {
    "build": "echo \"build patato\""
  }
}

Failure Logs / Configuration

{
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "version": "1.0.0",
  "npmClient": "yarn"
}

Environment

lerna notice cli v8.1.7

 Environment info:

  System:
    OS: Linux 5.15 Manjaro Linux
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  Binaries:
    Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
  Utilities:
    Git: 2.45.2 - /usr/bin/git
  npmPackages:
    lerna: ^8.1.7 => 8.1.7 
JamesHenry commented 1 month ago

@dboulardsc Sorry to hear that, issues that only happen under some niche circumstances are the worst, because I naturally can't repro either:

image

Some ideas to try (in order from simplest to most effort, not necessarily most likely to be the reason):

GregoireBellon commented 3 weeks ago

I face the same issue with npm and lerna 8.1.8.

I have two packages (@package/front and @package/back) that both share a dependency (@package/shared)

npx nx graph shows the dependency relationship, but the command lerna run build --scope @package/back--include-dependencies does not build my shared dependency.

The output is :

lerna notice cli v8.1.8
lerna notice filter including "@package/back"
lerna notice filter including dependencies
lerna info filter [ '@package/back' ]

> @package/back:build

> build
> nest build
... then fails irremediably

The package.json files are very similar to @dboulardsc 's ones, but the dependencies are declared like this :

  "dependencies": {
    "@package/shared": "*"
  }

The command used to work, and no package.json of the monorepo changed significantly, so I guess that the issue could have appeared in lerna 8.1.8 ?

ArthurG94 commented 3 weeks ago

I'm experiencing the same issue with Node 20.16.0 (via nvm), npm, and Lerna >= 8.1.3.

If I roll back to version 8.1.2, npx lerna list works again:

npm i -D lerna@latest
npx lerna list
#  lerna notice cli v8.1.8
#  lerna success found 0 packages

npm i -D lerna@8.1.3
npx lerna list
#  lerna notice cli v8.1.3
#  lerna success found 0 packages

npm i -D lerna@8.1.2
npx lerna list
#  lerna notice cli v8.1.2
#  @company/xxx-client
#  @company/xxx-server
#  lerna success found 2 packages

Project Architecture

  • client
    • package.json

      {
        "name": "@company/xxx-client",
        "version": "x.x.x"
        "scripts": {
            "eslint": "eslint --fix \"src/**/*.ts\" ",
            ...
        }
      }

  • server
    • package.json

      {
        "name": "@company/xxx-server",
        "version": "x.x.x",
        "scripts": {
            "eslint": "eslint --fix ./src/**/* --ext .ts",
            ...
        }
      }

  • package.json

    {
      "name": "@company/xxx",
      "private": true,
      "workspaces": [
          "server",
          "client"
      ],
      "scripts": {
          "eslint": "npx lerna run eslint",
          ...
      }
    }

  • lerna.json

    {
      "$schema": "node_modules/lerna/schemas/lerna-schema.json",
      "version": "5.4.1"
    }

Environment

  System:
    OS: Linux 6.8 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
    npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
  Utilities:
    Git: 2.43.0 - /usr/bin/git
  npmPackages:
    lerna: ^8.1.8 => 8.1.8