Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using yarn workspaces, how to force a package to be installed in the relative node_modules?

I love yarn workspaces, but more often than not I find myself having to pull out a specific package because of incompatibilities with external tools.

The main issue is that I don't have their source code in the relative node_modules, but a few levels above (which is normal for yarn workspaces and node, in general).

For instance, ZeppelinOS gives the following error message when "openzeppelin-eth" is not found in the relative path:

Could not find a zos.json file for 'openzeppelin-eth'. Make sure it is provided by the npm package.

Is there a way to force-copy a package? I read about --focus, but it's not what I need.

like image 538
Paul Razvan Berg Avatar asked Jul 06 '19 00:07

Paul Razvan Berg


1 Answers

What you're looking for is called nohoist https://yarnpkg.com/blog/2018/02/15/nohoist/

Basically you have two options:

  1. do it from the child package
"workspaces": {
  "nohoist": ["react-native", "react-native/**"]
}
  1. do it from the root level
"workspaces": {
  "packages": ["packages/*"],
  "nohoist": ["**/react-native", "**/react-native/**"]
}

If you want to share package xyz among all your sub-projects, then set it in the root, otherwise in the child project.

like image 146
Eduard Jacko Avatar answered Nov 24 '22 05:11

Eduard Jacko