-
-
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] Error in pnpm nuxt dev mode: Cannot use import statement outside a module #13917
Comments
Hello, can you give us a small code reproduction so we can debug this efficiently? :) |
Indeed, but my code is unremarkable. It is a brand-new, standard Nuxt project. Here is my
That's all. The rest is just the default Nuxt app scaffolding. |
I'll take a look at this |
I have found that the Nuxt application builds and runs fine, but the issue only occurs when running on localhost. To resolve this, we need to enable the nuxt module only for the build process. A temporary solution would be to edit the
|
I just checked this and with your project setup, I got the error only in development mode (with I also tried it with npm, yarn and pnpm v8.15 (so without the But great that you found a workaround! In your case it makes sense to only run Sentry when you are not in dev mode. Something like this might also work: modules: [
...(process.env.NODE_ENV !== 'development' ? ["@sentry/nuxt/module"] : [])
], |
Yes, the project runs properly when building with |
I implemented the changes successfully, but I'm encountering an issue with the Netlify build. The Nuxt config has a "start": "node --env-file=.env --import ./.nuxt/dist/server/sentry.server.config.mjs .nuxt/dist/server/index.mjs" The build has no issues, but Sentry doesn't catch any issues. |
Version 8.35.0 still preserves this behaviour |
I just tried it with |
Adding the |
I am going to use |
The error message looks similar but it's actually a slightly different one 😅 However, the error message in your screenshot says "Cannot find module ..." (it needs the I understand that this can feel frustrating, and we already filed an issue upstream to Nitro to fix the missing |
Hi 👋 Same issue as @trezorsix here, using yarn berry.
I found a very hacky way to get it to work, but wouldn't really recommend it. Basically leveraging Nuxt's lifecycle hooks to copy-pasting the missing files to
|
Hey @timhn-bm! Thank you for sharing your approach + workaround. Most of the SDK team is off on holiday tomorrow (long weekend), but we'll be back on Monday to take a look at this further. Appreciate the patience in the mean time. |
@s1gr1d adding For those who it may be helpful: add this to your
|
Docs for this are coming soon so I will close this issue. The docs PR: getsentry/sentry-docs#11720 Ideally, Sentry users who are using pnpm don't have to explicitly add this in the future so please check the docs for updates. |
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
8.33.1
Framework Version
Nuxt 3.13.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
Here is my configurations:
sentry.client.config.ts
sentry.server.config.ts
Steps to Reproduce
Expected Result
Nuxt app on the localhost have been successfully launched.
Actual Result
Getting 500 response from the Nuxt server instance:
The text was updated successfully, but these errors were encountered: