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

Installing with yarn berry doesn't work #2980

Closed
HaoboZ opened this issue Apr 4, 2022 · 11 comments
Closed

Installing with yarn berry doesn't work #2980

HaoboZ opened this issue Apr 4, 2022 · 11 comments

Comments

@HaoboZ
Copy link

HaoboZ commented Apr 4, 2022

Issue template

If you want to ask question, ask it in Github Discussions, Spectrum.chat or Slack channel

Please do not post unformatted code into issues, and please do not ask questions. Only real issues, PR or feature requests allowed. Minimal reproduction in codesandbox.io is must have.

Please provide an explanation

Following these steps, got an error for installation

@typescript/lib-dom@npm:@types/web: The remote server failed to provide the requested resource
Response Code: 404 (Not Found)
Request Method: GET
Request URL: https://registry.yarnpkg.com/@typescript%2flib-dom

  1. yarn create react-app testapp
  2. cd testapp
  3. yarn set version berry
  4. yarn add @react-google-maps/api

It works correctly with npm or not upgrading to yarn berry

Your Environment

os: tested on windows and mac

node --version
v16.13.0

react version
v18.0.0

webpack version

@babel version

@react-google-maps/api version
v2.8.1

How is it behave?

How should it behave correctly?

basic implementation of incorrect behavior in codesandbox.com

@JustFly1984
Copy link
Owner

@HaoboZ sorry I'm not a user of yarn berry, and I'm not sure what is broken, but typescript latest versions use @typescript/lib-dom@npm:@types/web since latest versions, and it works for yarn 1.22.x

@HaoboZ
Copy link
Author

HaoboZ commented Apr 4, 2022

Is there a possible fix for it? Every other package that I have installed, including typescript, works fine, just this one causes it to fail to install and I couldn't find anything online that worked for this particular bug.

@matthemsteger
Copy link

This also causes problems in our build pipeline. We use yarn 1.x and offline mirror.

--install.offline true
--install.frozen-lockfile true

This will error every time now because of this change. For some reason (it may be an upstream bug), the @types/web package is added while the install is happening, but then it is removed. This makes it so you must check this package into the offline mirror (node_offline for us) while you are installing so that the pipeline doesnt error while looking for this package (because install.offline is true).

But as a side effect, the next person who adds/removes a package will have the package again removed, and if they check that change in, then the build breaks again since this file is required by yarn.

I don't know the mechanics, but I do know that it seems using the npm: prefix is the culprit, and this is the only package we have encountered this problem on.

@JustFly1984
Copy link
Owner

@matthemsteger Can you please create an issue in their repo, and crosslink this issue there? Can you please provide minimal reproduction?

@matthemsteger
Copy link

@JustFly1984 I tried to find somewhere where someone wrote a spec for this kind of scheme, so I could perhaps come up with a simple reproduction, and the closest I could find is the NPM documentation at https://docs.npmjs.com/cli/v7/commands/npm-install

If we assume yarn is trying to keep up with this as a spec (??) .. it doesnt look like the way this dependency is defined in this repo is right? If you are using npm: .. then its for an alias and it should be <alias>@npm:<orig-package>. Do you need to do npm: here? I dont know how the package manger would respond to a null/blank/undefined alias.

@dachewster99
Copy link

@JustFly1984 , i have a similar issue when trying to install 2.8.0 or 2.8.1. This isnt an issue in 2.7.0 though
Error: @typescript/lib-dom@npm:@types/web isn't supported by any available resolver

@JustFly1984
Copy link
Owner

@dachewster99 @matthemsteger
It was added together with the latest typescript version by me.
I'm not sure why it does not work for you guys. Please post an issue in @types/web repo, and crosslink it here.

@gtwilliams03
Copy link

Same error installing with yarn 3.2.0:

yarn add @react-google-maps/api
YN0000: ┌ Resolution step
➤ YN0001: │ Error: @typescript/lib-dom@npm:@types/web isn't supported by any available resolver
    at wd.getResolverByDescriptor (/Users/xxx/react-app/.yarn/releases/yarn-3.2.0.cjs:395:1664)
    at wd.bindDescriptor (/Users/xxx/react-app/.yarn/releases/yarn-3.2.0.cjs:395:1053)
    at Z (/Users/xxx/react-app/.yarn/releases/yarn-3.2.0.cjs:441:6953)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
➤ YN0000: └ Completed in 1s 467ms
➤ YN0000: Failed with errors in 1s 469ms

@renchap
Copy link

renchap commented Apr 8, 2022

Here is the link to the Yarn issue: yarnpkg/berry#4334

And the Typescript issue implementing this change: microsoft/TypeScript#45771

According to those issues, the workaround is to force the version to a supported syntax using the resolutions field in package.json:

"resolutions": {
  "@typescript/lib-dom": "npm:@types/web@*"
}

@JustFly1984
Copy link
Owner

@renchap, Your solution is for end project repo. Doesn't work for lib repo.

@renchap
Copy link

renchap commented Apr 11, 2022

Yes, this is a workaround for end users, not a way to fix this in the project. I am not sure what to do on your side, except getting the bug fixed in Yarn.

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

6 participants