Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

309
Views
Yarn nohoist without using workspaces

One of my projects suddenly failed to compile on a Windows laptop, where the exact same code was working on a Mac. I've read about hoisting and adding nohoist, which seemed to fix the problem for Apollo client.

"workspaces": {
    "packages": [
      "packages/*"
    ],
    "nohoist": [
      "**/tslib",
      "**/tslib/**"
    ]
}

Now, I don't use workspaces, but since I am using the code above in package.json, Yarn asks for the -W parameter when adding or removing packages saying:

error Running this command will add the dependency to the workspace root rather than
the workspace itself, which might not be what you want - if you really meant it, make it
explicit by running this command again with the -W flag (or --ignore-workspace-root-check).

It doesn't seem to me like this is the best way to go. What should I do?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

By adding the workspaces config in your package.json you have enabled the use of workspaces. This is why you're getting the warning about adding the dependency to the workspace root. nohoist is a workspace only option; it was created to enable 3rd party libraries that are not compatible with the yarn workspace hoisting scheme to still be used under workspaces. See https://classic.yarnpkg.com/blog/2018/02/15/nohoist/

“nohoist” enables workspaces to consume 3rd-party libraries not yet compatible with its hoisting scheme. The idea is to disable the selected modules from being hoisted to the project root. They were placed in the actual (child) project instead, just like in a standalone, non-workspaces, project.

If you don't want to use workspaces, you need to remove the workspace configuration from your package.json and fix your compilation issue another way.

about 4 years ago · Juan Pablo Isaza Report

0

Actually, it is the proper way to exclude some packages which it is needed to have different versions of them in your workspaces packages by using the below config:

"workspaces": {
  "nohoist": [
    "**/[package-name]",
    "**/[package-name]/**"
  ]
}

This will help to have successful build.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!