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] Typescript 4.3.2 Cannot apply hunk #2 #2952

Closed
1 task
phuctm97 opened this issue May 29, 2021 · 2 comments
Closed
1 task

[Bug] Typescript 4.3.2 Cannot apply hunk #2 #2952

phuctm97 opened this issue May 29, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@phuctm97
Copy link
Contributor

  • I'd be willing to implement a fix

Describe the bug

Can't install TypeScript v4.3.2.

Received this:

➤ YN0013: │ typescript@npm:4.3.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ typescript@patch:typescript@npm%3A4.3.2#builtin<compat/typescript>::version=4.3.2&hash=a45b0e can't be found in the cache and will be fetched from the disk
➤ YN0013: │ typescript@npm:4.3.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0066: │ typescript@patch:typescript@npm%3A4.3.2#builtin<compat/typescript>::version=4.3.2&hash=a45b0e: Cannot apply hunk #2 (set enableInlineHunks for details)

A clear and concise description of what the bug is. A bug is unintended. A feature not being
implemented is not a bug, and your issue may be closed for misleading labeling.

To Reproduce

The minimal information needed to reproduce your issue (ideally a package.json with a single dep).
Note that bugs without minimal reproductions will be closed as non-actionable.

  • Create a new repo
  • yarn init -2
  • yarn
  • yarn add -D typescript

Screenshots

If applicable, add screenshots to help explain your problem.

Environment if relevant (please complete the following information):

  • OS: [e.g. OSX, Linux, Windows, ...] macOS Big Sur
  • Node version [e.g. 8.15.0, 10.15.1, ...] 14.17.0
  • Yarn version [e.g. 2.4.0, ...] 2.4.1
@phuctm97 phuctm97 added the bug Something isn't working label May 29, 2021
@merceyz
Copy link
Member

merceyz commented May 29, 2021

Duplicate of #2938

@codespearhead
Copy link

codespearhead commented Jan 1, 2023

I just encountered this issue when trying to install the latest version of NextJS via [1], and I noticed [2] yielded the same error message as the one described in the issue, which I was able to reproduce by running the three commands the original poster provided.

[1] npx create-next-app@12 --ts
[2] yarn create next-app@12 --ts

Once I removed the "--ts" flag, both of them worked without any errors, which further proves there's something wrong with the Typescript installation, especially because replacing "@12" with "@latest" solved the issue.

Upon closer inspection, I realized that it both [1] and [2] would default to install packages with Yarn since it's available globally on my machine. Once I uninstalled Yarn via [3] and ran [1], the NextJS installation proceeded via NPM without any errors.

[3] npm -g uninstall yarn

According to this user, Yarn patches TypeScript to add support for PNP, which sometimes goes bad and in my opinion should be an opt-in (and potential headache) for YARN PNP users only. Otherwise the only way out I found for NPM and YARN users is to get rid of Yarn altogether.

Since I don't have the expertise to make a pull request, here's my configuration [4] for anyone who's willing to work on that:

[4]

  • OS: Fedora Linux 36 (Workstation Edition)
  • Node: v18.12.1
  • NPM: v8.19.2
  • Yarn: v2.4.3 (but it happens on Yarn 3.3.1, too)
  • Other: All the above are in the path and only Yarn is installed globally

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