这是indexloc提供的服务,不要输入任何密码
Skip to content

fix(yarn-pnp): fixing generateBinPath when yarn pnp is enabled #795

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

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

thebanjomatic
Copy link
Contributor

@thebanjomatic thebanjomatic commented Mar 1, 2022

As mentioned here: #693 (comment)

The call to require.resolve(turbo) was failing because the package does not have a main export
defined in the package.json, nor is there an index.js. Since we are just looking for the directory
the package is unplugged into, we can resolve the path to the package.json and get the dirname
of that.

This basically fixes things to the point where the binary is able to execute before hitting the nodeLinker
checks and bailing out with a proper error message.

Before:

> yarn turbo --version
C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\bin\turbo:13
    throw e;
    ^

Error: Qualified path resolution failed - none of those files can be found on the disk.

Source path: C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\
Not found: C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\
Not found: C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\.js
Not found: C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\.json
Not found: C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\.node
Not found: C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\index.js
Not found: C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\index.json
Not found: C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\index.node

Require stack:
- C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\node-platform.js
- C:\source\test-repo\.yarn\unplugged\turbo-npm-1.1.4-c2216ae885\node_modules\turbo\bin\turbo

After:

> yarn turbo --version
1.1.4
> yarn turbo run build
 ERROR  only yarn v2/v3 with `nodeLinker: node-modules` is supported at this time

@vercel
Copy link

vercel bot commented Mar 1, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/vercel/turbo-site/ELh1KRp4MSgPuyBA1YyAc3NXnnjY
✅ Preview: https://turbo-site-git-fork-thebanjomatic-fix-yarn-pnpnode-platform.vercel.sh

The call to require.resolve(turbo) was failing because the package does not have a main export
defined in the package.json, nor is there an index.js. Since we are just looking for the directory
the package is unplugged into, we can resolve the path to the package.json and get the dirname
of that.
@gsoltis gsoltis merged commit d8e1b85 into vercel:main Mar 1, 2022
@thebanjomatic thebanjomatic deleted the fix/yarn-pnp/node-platform branch March 1, 2022 17:56
kodiakhq bot pushed a commit that referenced this pull request Mar 8, 2022
Regarding #693 (comment) I believe this at least partially addresses Issue: #693, but the scope of the issue is unclear.

More specifically this removes the general check for yarn pnp and moves it into the prune command instead as this is the part that likely has remaining issues with pnp since nothing else that I'm aware of needs to know about `node_modules`.

This PR builds off of #795, as otherwise you can't even run turbo to be able to hit the previous nodeLinker checks.

Let me know if you would like me to change things around so that it is more explicitly enabling for the run task as opposed to enabling for all but prune.
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

Successfully merging this pull request may close these issues.

2 participants