pnpmpnpm-workspace

Why is the node_modules link for my pnpm workspace sometimes the local package's root and sometime its dist folder?


I'm having a frustrating problem that I'd like to better understand. I've just switched from yarn classic to pnpm. Sometimes my build fails because one of my local package's node_modules link points not to the package root, but to it's output directory 'dist'. The weird thing is this is not consistent and not for every project, in particular rollup based libraries don't do this, but webpack based libraries (long story) do this. I saw something about metaDependencies inject, but I'm not using that setting. Anyone know what's going on?

I think I've fixed it by adding the last 2 lines in my .npmrc

recursive-install = true
node-linker=hoisted
shell-emulator = true
link-workspace-packages = true
prefer-workspace-packages = true

But I don't understand why that would do that. I'm already using 'workspace:*' for my version everywhere so I'm not supposed to need link-workspace-packages


Solution

  • I had put packages/** instead of package/* in my pnpm-workspaces.yaml file so it was seeing the dist folder as a package and overwriting the workspace folder lol