jayarjo
jayarjo

Reputation: 16716

Force yarn to install certain modules to given workspace, rather than moving them to shared node_modules of monorepo?

I have a monorepo (via yarn workspaces). One of the workspaces is a React app created via Create React App (I think this is important, because CRA puts Webpack/Babel in its own node_modules). Another workspace is a pure JavaScript package with its own set of Webpack + Babel tools.

My problem is that when I'm launching build from the pure JavaScript workspace, I get these:

enter image description here

However when I separate the workspace into a standalone directory (using copy/paste) and build from there, it builds perfectly fine.

So my guess was there's something wrong with the monorepo itself. I also noticed that specified workspace lacks @babel, babel-runtime and regenerator-runtime in local node_modules, so I copy/pasted them from the monorepo's main node_modules folder and then the whole thing built fine. Now this is obviously some flaw in the architecture of the yarn monorepo and Webpack + Babel junction.

Is it possible to force yarn to install specific modules into the local node_modules, rather than "helping me out" by moving them to the shared node_modules in the root of monorepo?

Upvotes: 5

Views: 1764

Answers (1)

Alexander
Alexander

Reputation: 1380

You can use nohoist. This will indicate which modules should be installed locally for the package.

Upvotes: 5

Related Questions