2

I'm using Lerna with a monorepo typescript app, that has this structure:

app/
  backend/package.json
  frontend/package.json
  common/package.json
./package.json

I'm also using yarn to install dependencies.

My lerna.json is like:

{
  "packages": [
    "app/*"
  ],
  "version": "0.0.0",
  "npmClient": "yarn",
  "useWorkspaces": true
}

My root package.json is like:

"workspaces": [
    "app/*"
  ],

Each one has is own package and the root has common packages.

I need to generate the node_modules of only the backend prod package.

How can I do that?

RobC
  • 22,977
  • 20
  • 73
  • 80
  • You can do yarn --cwd=backend, no need to use lerna. Duplicate of https://stackoverflow.com/questions/46891622/run-yarn-in-a-different-path – Komninos May 21 '20 at 19:41
  • 1
    @Komninos, this does not work. When I run that, it install all dependencies of all workspaces in the root path. They are all connected in the root package.json. – Leonardo Campanha May 21 '20 at 19:57
  • I'm sorry there was a typo in the command. Try `yarn --cwd=app/backend` this basically runs the yarn command inside your backend project folder which is what Lerna would do as well. There is no reason for Lerna to add such functionality because you can do it through yarn :) – Komninos May 21 '20 at 20:05
  • 1
    The command still doesn't work. When I run this, install all workspaces node_modules in the root path, @Komninos – Leonardo Campanha May 21 '20 at 20:11

0 Answers0