Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I make lerna install devDependencies with "lerna bootstrap --hoist"? #1765

Closed
wbern opened this issue Nov 7, 2018 · 6 comments
Closed

Comments

@wbern
Copy link

wbern commented Nov 7, 2018

#505

Expected Behavior

I'd like to run lerna bootstrap --hoist and have each package get their devDependencies installed, either in its own directory or in the root.

Current Behavior

devDependencies are ignored.

Possible Solution

Here's a workaround, in the package package.json

"prepare": "if-env lerna=1 && npm install --only=dev || echo 'skipping devDependencies"
actually this doesn't really seem to work either.

Steps to Reproduce (for bugs)

  1. make a package
  2. add a devDependency to it
  3. run lerna bootstrap --hoist
  4. the devDependency is nowhere to be found
lerna.json

{
    "version": "0.0.0",
    "packages": [
      "micro-apps/*/*",
      "shared-apps/*"
    ],
    "command": {
      "publish": {
        "ignoreChanges": [
          "ignored-file",
          "*.md"
        ],
        "independent": true
      },
      "bootstrap": {
        "npmClientArgs": []  
      }
    },
    "useWorkspaces": false
  }
 

Context

We have a monorepo where the root project dir is another legacy project.

We therefore don't want to stash all our devDependencies into the project root package.json, because it will generate confusion what belongs where.
Someday we might move the legacy project to a sub package directory, but we can't do that right now.

Your Environment

Executable Version
lerna --version 3.4.3
npm --version 5.6.0
yarn --version VERSION
node --version 8.11.3 (LTS)
OS Version
Ubuntu 17.x
@wbern
Copy link
Author

wbern commented Nov 7, 2018

Ok, so I'm slightly confused but it might make sense too, hear me out.

If I have sub packages in my lerna monorepo, and do lerna bootstrap or lerna bootstrap --hoist, the devDependencies get installed in either case.

Update: See my next comment for a better work-around

If I however have sub packages just like before, but also install them in the root directory's package.json-file, the packages get installed as external dependencies instead, and external dependencies as a general rule in the world of npm, rightfully skips devDependencies.

I guess this is correct?

In our case, it doesn't quite help us. We might need to execute some npm command to install devDependencies in each sub package.. I'll update here when we've done it.

@wbern
Copy link
Author

wbern commented Nov 16, 2018

Ok, I found the best possible work-around.

Add the packages in the root as "devDependencies". If they are consumed by webpack (like in my case), it doesn't matter if they are in devDependencies, webpack will produce them in the output directory anyway.

Here's some discussion about whether it's right or not to use devDependencies. webpack/webpack#520

@evocateur
Copy link
Member

I would just run npx lerna link convert and stop worrying about bootstrap or hoisting. I'm a little unclear why you need to keep the root in some legacy state, seems like the transition to lerna would be a good opportunity to shed that technical debt...

@wbern
Copy link
Author

wbern commented Nov 28, 2018

@evocateur I think the bootstrapping is an awesome function. We don't always want to symlink things if we don't consume the latest versions of things, and we have a lot of duplicate dependencies which hoist helps us take care of.

Yes, we plan to move the root soon but it's a lot of stuff to move. We have a huge AngularJS app and it's been tricky to transition to micro frontends using lerna, but we're definitely getting there.

@wbern
Copy link
Author

wbern commented Jan 3, 2019

Closing this issue, I feel it's resolved.

@wbern wbern closed this as completed Jan 3, 2019
@lock
Copy link

lock bot commented Apr 3, 2019

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants