Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Installing a hybrid mono-repo with node-modules nmLinker package inside a pnp nmLinker root causes package to install itself in circular dependency loop #4232

Closed
inlightmedia opened this issue Mar 17, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@inlightmedia
Copy link

inlightmedia commented Mar 17, 2022

Describe the bug

I'm trying to install a node-modules linker package inside a root mono repo with pnp. I need the node-modules linker package to use node-modules and for it to also recognize all the other packages and be able to import them.

I have a yarnrc.yml in the root with:

nmLinker: pnp
and
pnpIgnorePattern set to the package using node-modules

I have a package in the monorepo with a installConfig with hoistingLimits: workspaces

It seems to install all the pnp packages in the root when I run yarn in the root. When I run yarn in the node-modules linked package it installs all the dependencies and also installs all the shared sibling packages in the node-modules linked package which is great. However, it also installs itself... again and again in a dependency loop.

I've made a simple reproduction repo.

To reproduce just run yarn install in the root and then run it again from within the "nm" package.

Ultimately, I am trying to get our node_modules based react native project working in our pnp based monorepo. Following the instructions from the hybrid pnp+node_modules tutorial makes the react native project unable to detect the sibling packages that it depends on (we had it all working great in yarn 1 using no hoist - just no pnp). My current technique above seems to work great except for the circular dependency issue.

See the following repo for a minimal reproduction:

https://github.com/inlightmedia/yarn-monorepo-pnp-nm-loop

To reproduce

clone the git hub repo: https://github.com/inlightmedia/yarn-monorepo-pnp-nm-loop
yarn install in root
cd into the nm package
yarn install in the nm package

Note how the node_modules folder it produces has a circular dependency loop where the nm package is installed in itself.

On larger projects, eventually it crashes and the install never completes. This is more noticeable on larger projects.

Environment

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
  Binaries:
    Node: 16.5.0 - /private/var/folders/jn/9q00jrz1309_yfxgxtqys1vh0000gn/T/xfs-890c2bc5/node
    Yarn: 3.2.0 - /private/var/folders/jn/9q00jrz1309_yfxgxtqys1vh0000gn/T/xfs-890c2bc5/yarn
    npm: 7.19.1 - /usr/local/bin/npm

Additional context

No response

@inlightmedia inlightmedia added the bug Something isn't working label Mar 17, 2022
@larixer
Copy link
Member

larixer commented Mar 28, 2022

If you don't want self-references, you can disable them via nmSelfReferences: false in your .yarnrc.yml:
https://yarnpkg.com/configuration/yarnrc#nmSelfReferences

@rxliuli
Copy link

rxliuli commented Aug 24, 2022

nmSelfReferences

This default value is weird, and multi-platform behavior is inconsistent. . .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants