Skip to content

[Bug?]: Yarn removes files from dependency #7014

@rochdev

Description

@rochdev

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/npm

Additional context

I'm guessing this also applies to bundledDependencies since those dependencies would be included directly in the package as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnot a bugwaiting for feedbackWill autoclose in a while unless more data are provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions