-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Self-service
- I'd be willing to implement a fix
Describe the bug
Yarn removes files from a dependency that are required for the dependency to function. For example, our library includes a node_modules folder in a subdirectory to make those modules available to all files by their name instead of a relative path. This is a pattern supported by Node and has (or should have) nothing to do with package managers as the files exists in the repository and the package and are not installed as subdependencies. But when the library is added to a project as a dependency, Yarn deletes this folder.
While I understand the behaviour of deleting modules from node_modules when those modules are defined as dependencies and moving them for PnP, in our case it's just a folder that is included and not related to package management in any way. They're not downloaded, they're not versioned, they don't even have a package.json. It's just a folder that is bundled with the dependency.
Unless there is a way to work around this at the dependency level (not at the app level since that would require all dependees to know how to work around the issue), I consider this a bug since it goes directly against how Node works.
To reproduce
Instructions at https://github.com/rochdev/yarn-deleting-node-modules-bug
Environment
System:
OS: Linux 6.10 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (10) arm64 unknown
Binaries:
Node: 22.21.1 - /tmp/xfs-8bef7aeb/node
Yarn: 4.12.0 - /tmp/xfs-8bef7aeb/yarn
npm: 10.9.4 - /usr/local/bin/npmAdditional context
I'm guessing this also applies to bundledDependencies since those dependencies would be included directly in the package as well.