Giter VIP home page Giter VIP logo

Comments (2)

wqcstrong avatar wqcstrong commented on June 10, 2024

I try to run lerna publish prerelase in other test repo, and the packages be successful published!

from lerna.

wqcstrong avatar wqcstrong commented on June 10, 2024

If others encounter the same situation as mine, here is my solution.

What happend?

The demo file structure in my monorepo:

├── lerna.json
├── nx.json
├── package.json
├── packages
│   ├── base
│   ├── is-even
│   └── is-odd
└── yarn.lock

I only want to publish two packages, packages/is-even and packages/is-odd. The packages/base directory contains utility functions and is not intended to be published as a package. Therefore, I have set packages/base as private:

// packages/base/package.json
{
  "private": true,
  "description": "Base utils"
}

Another necessary content occur the issue which should know is "workspaces" in my root package.json:

// package.json
{
  "name": "root",
  "private": true,
  "workspaces": [
    "packages/*"
  ],
  "dependencies": {},
  "devDependencies": {
    "lerna": "^8.0.0",
    "nx": "17.2.8"
  }
}

Deep dive

Well, I thought lerna would filter and exclude packages/base first because they are private. Indeed, lerna does do that, but before excluding them, lerna also reads private packages to obtain metadata information. This is because packages/base matches the definition in the root package.json under workspaces: ["packages/*"]. During the metadata reading process, lerna reads the "name" property of sub-packages, and since packages/base does not define a "name," it leads to the occurrence of this issue.

Solutions

  • option 1: add "name" property in packages/base, or
  • option 2: update workspaces: ["packages/is-*"] in root package.json;

After the update, lerna publish from-package works properly! 😄

from lerna.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.