sentry-javascript
sentry-javascript copied to clipboard
ReferenceError: require is not defined in ES module scope
Is there an existing issue for this?
- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [X] I have reviewed the documentation https://docs.sentry.io/
- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
7.93
Framework Version
Next 14.0.4
Link to Sentry event
No response
SDK Setup
Sentry.init({ dsn: "https://d3d453abcf893d156c4b1089f47dbcb3@o4506556375302144.ingest.sentry.io/4506556395487232",
tracesSampleRate: 1, debug: false, replaysOnErrorSampleRate: 1.0, replaysSessionSampleRate: 0.1,
integrations: [ new Sentry.Replay({ maskAllText: true, blockAllMedia: true, }), ], });
// Comments removed
Steps to Reproduce
- Directly after finishing the wizard, I ran into the error, I noticed it at build time using run dev.
I may just be tired and did something wrong and I will try it again tomorrow. First time trying to build with sentry so i'm not going to promise i didn't mess something up. I'll do the manual config tomorrow.
Expected Result
app compiles and loads
Actual Result
file:///Users/daniel/Code/hivemind/next.config.js:18 const { withSentryConfig } = require("@sentry/nextjs"); ^
ReferenceError: require is not defined in ES module scope, you can use import instead This file is being treated as an ES module because it has a '.js' file extension and '/Users/daniel/Code/hivemind/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension. at file:///Users/daniel/Code/hivemind/next.config.js:18:30
Node.js v20.10.0 ELIFECYCLE Command failed with exit code 1.
Hi, it seems like you have set "type": "module" in your package.json. This means you can't have your next.config.js be a CJS .js file. Can you either try removing the "type": "module" flag or converting your next.config.js to ESM? Thanks!
Hey @tomosovich did you manage to solve the issue?
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀