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

[Next.js] Figure out a way to silence the import/require-in-the-middle warnings for Turbopack #15070

Open
lforst opened this issue Jan 20, 2025 · 9 comments

Comments

@lforst
Copy link
Member

lforst commented Jan 20, 2025

Description

Seems like Turbopack is more strict in what it will do when there would be 2 different versions of a package it could bundle. Currently it will refuse to build (?). Maybe we can iron out the kinks here.

 ⚠ ./node_modules/.pnpm/@opentelemetry+instrumentation@0.56.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
Package import-in-the-middle can't be external
The request import-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install import-in-the-middle from the project directory.
@benjick
Copy link
Contributor

benjick commented Feb 17, 2025

Can these be ignored?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 17, 2025
@timfish
Copy link
Collaborator

timfish commented Feb 17, 2025

Which warnings are these and what do they look like? Do these warnings still exist now that in v9 we use import-in-the-middle in a mode where it doesn't attempt to instrument everything?

@benjick
Copy link
Contributor

benjick commented Feb 18, 2025

These are the ones I get:

 ○ Compiling /login ...
 ✓ Compiled /login in 1488ms
 ⚠ ./node_modules/.pnpm/@opentelemetry+instrumentation@0.56.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
Package import-in-the-middle can't be external
The request import-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install import-in-the-middle from the project directory.


 ⚠ ./node_modules/.pnpm/@opentelemetry+instrumentation@0.57.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
Package import-in-the-middle can't be external
The request import-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install import-in-the-middle from the project directory.


 ⚠ ./node_modules/.pnpm/@sentry+node@9.1.0/node_modules/@sentry/node/build/cjs/sdk
Package import-in-the-middle can't be external
The request import-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install import-in-the-middle from the project directory.


 ⚠ ./node_modules/.pnpm/@opentelemetry+instrumentation@0.56.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
Package require-in-the-middle can't be external
The request require-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install require-in-the-middle from the project directory.


 ⚠ ./node_modules/.pnpm/@opentelemetry+instrumentation@0.57.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
Package require-in-the-middle can't be external
The request require-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install require-in-the-middle from the project directory.
  • next@15.1.7
  • @sentry/nextjs@9.1.0

@novelnet
Copy link

having same issues, two different versions of import-in-the-middle in @sentry/node@9.8.0 causing the warnings
⚠ ./node_modules/@opentelemetry/instrumentation/build/esm/platform/node Package import-in-the-middle can't be external The request import-in-the-middle matches serverExternalPackages (or the default list). The package resolves to a different version when requested from the project directory (1.13.1) compared to the package requested from the importing module (1.11.2). Make sure to install the same version of the package in both locations.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 24, 2025
@lforst
Copy link
Member Author

lforst commented Mar 24, 2025

@novelnet Yes, this is fixed by adding an override to your package manager to install one specific version. In the case of import-in-the-middle, the later version is usually the better choice.

@novelnet
Copy link

@lforst thank you, but means to keep track on all sentry updates which may change package versions. Would be nice to fix this on sentry's side

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 24, 2025
@lforst
Copy link
Member Author

lforst commented Mar 24, 2025

This is not 100% fixable on our side. We are not in control of other dependencies and what they install.

@MonstraG
Copy link
Contributor

MonstraG commented Apr 3, 2025

What should we do with the OP's case? (Not the version mismatch).

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 3, 2025
@lforst
Copy link
Member Author

lforst commented Apr 3, 2025

@MonstraG maybe what the error message suggests?

Try to install it into the project directory by running npm install import-in-the-middle from the project directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

7 participants