Workspaces with “nohoist”: [“**”] fails with ENOENT error

What is the current behavior?

On a large monorepo project with 5+ packages, adding "nohoist": ["**"] to the root package.json results in ENOENT errors, for example:

error An unexpected error occurred: "ENOENT: no such file or directory, lstat '/Users/ryanashcraft/Work/javascript/packages/eslint-config-amplitude-base/node_modules/table/node_modules/lodash'".
info If you think this is a bug, please open a bug report with the information provided in "/Users/ryanashcraft/Work/javascript/yarn-error.log".

/Users/ryanashcraft/Work/javascript/packages/eslint-config-amplitude-base/node_modules/table/node_modules is an empty directory.

If the current behavior is a bug, please provide the steps to reproduce.

This project is closed-source, so I can’t provide a link. Happy to provide more information about the project if helpful.

What is the expected behavior?

The install succeeds, and all packages are not hoisted to the root repo directory.

Please mention your node.js, yarn and operating system version.

yarn: v1.13.0
node: v10.15.0
macOS: 10.14.2

Related issues.

I decided to make a separate issue for this as it relates specifically to configuring "nohoist": ["**"]:


Author: Fantashit

1 thought on “Workspaces with “nohoist”: [“**”] fails with ENOENT error

  1. I’m running into this issue as well. I’ve created a simple reproduction repo here:


    • Narrowed down from my real-life dependencies to css-loader in package b using half splitting. However, the actual file/directory that was missing changed throughout the process — from /packages/b/node_modules/json5 to /packages/b/node_modules to finally /packages/b/node_modules/css-loader.
    • Cannot reproduce when major versions of css-loader are the same (e.g. no issues on install when both package a and b have "css-loader": "^1.0.0" specified.)
    • Cannot reproduce when package a does not reference package b in dependencies/devDependencies.
    • Cannot reproduce when package a has "nohoist": ["css-*"] or "nohoist": ["css-loader"].

Comments are closed.