-
Notifications
You must be signed in to change notification settings - Fork 69
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
wrong package.json being read when used with yarn workspaces #87
Comments
I think it is caused by this line: https://github.com/ilearnio/module-alias/blob/dev/index.js#L166 The order of the items in the array should be reversed. |
So first, I confirm that this is an issue. @andreialecu's workaround will work in the consuming package, but since the problem applies to any package in your tree that uses module-alias, a better workaround is to switch to the new workspaces specification syntax in the top-level package.json file. Here's a complete, if minimal file:
With this syntax, the As to the bug itself, I don't (quite) agree with @andreialecu's proposed solution, but I do agree that the code at https://github.com/ilearnio/module-alias/blob/dev/index.js#L166 and following is not correct. If I actually think there are two bugs here. The first is that there is no way to set the The second bug (as I said above) is that the search strategy seems wrong. My initial thought was that we should start at either
That is: look in all of the directories that are above one of the module resolution directories. Just a thought. |
Hi there ! I'll try and look into it, I'm unfamiliar with yarn workspaces. Re: the point about dependencies using Re: the point about "but then I realized that the package.json will always be in the directory above the |
WOW, it took me forever to find this. Thank you @andreialecu for creating this issue. It's a shame that the extremely easy fix isn't widely known or shared 😢 So again, what worked for me was:
|
Just bumped into this issue. Note that newer Yarn no longer has Set nmHoistingLimits to |
Ran into an issue when using yarn workspaces hoisting. Because the
module-alias
directory will be hoisted to the top level of the project, it will read thepackage.json
from the workspace root instead of the package's directory instead.This will break aliases.
A workaround for this is to disable hoisting for module-alias on a package level, eg:
packages/somepkg/package.json
Then re-run
yarn install --force
.I think ideally this should be handled without disabling hoisting.
The text was updated successfully, but these errors were encountered: