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

Yarn PnP activating when project has nodeLinker: node-modules #3876

Open
MaxLap opened this issue Aug 13, 2024 · 2 comments
Open

Yarn PnP activating when project has nodeLinker: node-modules #3876

MaxLap opened this issue Aug 13, 2024 · 2 comments

Comments

@MaxLap
Copy link

MaxLap commented Aug 13, 2024

It seems that if my home folder contains a .pnp.cjs file, esbuild uses PnP even if the project itself is configured with nodeLinker: node-modules in its .yarnrc.yml.

I'm not sure if the problem is on esbuild or on Yarn.

I'm on WSL2 with Ubuntu 24.04, with esbuild 0.23.0, yarn 4.3.0. I just did a fresh install. Installed nvm, then node 20, then corepack enable. My project was already setup for node-modules mode with its .yarnrc.yml.

Every package would be unresolvable within esbuild. Using verbose logging, I got this kind of output for each import:

● [DEBUG] Resolving import "tailwindcss-stimulus-components" in directory "/home/max/projects/documold/app/javascript/controllers" of type "import-statement"

  Checking for package alias matches
    Failed to find any package alias matches
  Read 26 entries for directory "/home/max/projects/documold/app/javascript/controllers"
  No "browser" map found in directory "/home/max/projects/documold/app/javascript/controllers"
  Searching for "tailwindcss-stimulus-components" in "node_modules" directories starting from "/home/max/projects/documold/app/javascript/controllers"
    Using Yarn PnP manifest from "/home/max/.pnp.cjs"
      Resolving "tailwindcss-stimulus-components" in "/home/max/projects/documold/app/javascript/controllers"
      Parsed bare identifier "tailwindcss-stimulus-components" and module path ""
      Found parent locator: ["max", "workspace:."]
      Found parent package at "./"
      Failed to find "tailwindcss-stimulus-components" in "packageDependencies" of parent package
      Searching for a fallback because "enableTopLevelFallback" is true
        Stopping because ["max", "workspace:."] is in "fallbackExclusionList"
    The Yarn PnP path resolution algorithm returned an error

If I rename the .pnp.cjs file from my home dir, then things work and pnp is not used.

My understanding is that nodeLinker: node-modules in the project's .yarnrc.yml should turn pnp off for that project. But it clearly doesn't (at least for esbuild). Am I doing something wrong? I'm just hoping to save someone else's time since the logs without verbose are not helpful for this issue.

Thanks

@MaxLap MaxLap changed the title Yarn PnP activating when project has Yarn PnP activating when project has nodeLinker: node-modules Aug 13, 2024
@MaxLap
Copy link
Author

MaxLap commented Aug 13, 2024

I'm not sure it's normal for there to be a .pnp.cjs file in the home dir. I may have accidentally initiated a project in my home dir. No idea how that happened, but I also had a .git directory there...

After a 2nd fresh install, I did not get a "random" .pnp.cjs in my home dir, and things worked fine. So maybe then it looked like nested project which I don't know the expected behavior of, but doesn't concern me. Feel free to close. Sorry for the trouble

@merceyz
Copy link

merceyz commented Aug 14, 2024

Duplicate of #2647

I may have accidentally initiated a project in my home dir

That's the most likely explanation, Yarn shouldn't write it to the home directory unless you run an install there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants