-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Nuxt] Node server config import results in ReferenceError: require is not defined in ES module scope, you can use import instead #15423
Comments
I have the same issue 👍 |
I have an issue using |
I semi-resolved issues with Sentry in Nuxt using nightly Nuxt 3x and hardcoding require-in-the-middle version < 7.5 But these issues should not exist with a very basic Nuxt + Sentry init setup
The issue is not with the pnpm as far as I know as sentry dep is not just bundled correctly |
I have the same issue |
It looks like this is caused by Vite bundling Can anyone confirm that this is only an issue with pnpm + vite and doesn't occur with npm? |
Does enabling the pnpm
|
@timfish I won't be able to confirm with npm right now. Hopefully someone else will be able to confirm. |
I just debugged this with @Lms24 and the only workaround right now is disabling Sentry in dev mode or using another package manager. The file import referenced in the "Cannot find module" error is correct - both files exist in If you would add the |
OR switching to a sane package manager, like npm or yarn :) |
If this only occurs in dev mode, you might be seeing this issue or some variation of it: |
@s1gr1d Disabling the Sentry in dev mode does not work as when you import anything from Sentry like captureException it will try to bundle the Sentry during build and will cause broken dev mode @Lms24 Is it a pnpm issue when updating Nuxt to nightly fixes it? :-) All our issues with Sentry + Nuxt were resolved using #15423 (comment) I just wanted to mention it so more people don't burn multiple hours trying to integrate Sentry with Nuxt |
I've been looking into the issue with This issue is only reproducable when pnpm and Vite are used together. I don't know enough about how pnpm works to know whether this is specifically caused by pnpm or Vite, but this is not an issue with either npm or yarn.
Forcing You can see the full discussion here: |
that makes sense, thanks! |
|
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nuxt
SDK Version
9.1.0
Framework Version
Nuxt 3.15.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
Those files were created using the commands in steps:
sentry.client.config.ts
sentry.server.config.ts
nuxt.config.ts
package.json
Steps to Reproduce
pnpm dlx nuxi@latest init test
cd test
pnpm i
npx @sentry/wizard@latest -i nuxt --saas --org REDACTED --project nuxt-test
pnpm i
pnpm run build
node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs
We reproduced this on two different machines (MacOS)
Expected Result
The built Nuxt application will run with imported Sentry server config
Actual Result
node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs
The text was updated successfully, but these errors were encountered: