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?]: Module not found: Can't resolve '@sentry/utils/esm/buildPolyfills' #5489

Closed
1 task
HoJin9622 opened this issue Jun 6, 2023 · 2 comments
Closed
1 task
Labels
bug Something isn't working

Comments

@HoJin9622
Copy link

HoJin9622 commented Jun 6, 2023

Self-service

  • I'd be willing to implement a fix

Describe the bug

Sentry gets an error when using yarn berry.
There was no problem with the version of yarn 1.x.x, but there is a problem with berry.
When entering the page, the error Can't resolve '@sentry/utils/esm/buildPolyfills' appears.

To reproduce

Reproduction app

Environment

System:
    OS: macOS 13.3.1
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 16.17.1 - /private/var/folders/0l/pfyzs64132zg_wwf69czqrnw0000gn/T/xfs-5036e623/node
    Yarn: 3.6.0 - /private/var/folders/0l/pfyzs64132zg_wwf69czqrnw0000gn/T/xfs-5036e623/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm

Additional context

getsentry/sentry-javascript#8180

No response

@HoJin9622 HoJin9622 added the bug Something isn't working label Jun 6, 2023
@Huespal
Copy link

Huespal commented Jun 8, 2023

Hello.
Our team is experiencing the same.
Do you have a date when it will be fixed?
Thank you.

@merceyz
Copy link
Member

merceyz commented Jun 8, 2023

This is not a bug in Yarn and is behaving as expected.

Something in your build pipeline is injecting unresolved imports to @sentry/utils which requires you to declare it as a dependency to access it.
Since that isn't a great developer experience the preferred solution is for the import to be resolved before getting injected.

Console output in debug mode:

$ PNP_DEBUG_LEVEL=1 yarn build

Your application tried to access @sentry/utils, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

  In ← '@sentry/utils'
  In ← '/app/next-sentry-error-example/src/app/'
  In ← { considerBuiltins: false }

There was no problem with the version of yarn 1.x.x, but there is a problem with berry.

That's because Yarn 1.x hoists @sentry/utils so it's accessible to your project, Berry can do that as well if you run

yarn config set nodeLinker node-modules
yarn

See https://yarnpkg.com/advanced/rulebook/#packages-should-only-ever-require-what-they-formally-list-in-their-dependencies for more information on hoisting.

@merceyz merceyz closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
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