Skip to content

Uncaught ReferenceError: require is not defined - when using ES Modules #1994

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

Closed
3 of 7 tasks
wsloth opened this issue Apr 4, 2019 · 3 comments
Closed
3 of 7 tasks

Comments

@wsloth
Copy link

wsloth commented Apr 4, 2019

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.0.5

Description

When doing one of the following:
import * as Sentry from '@sentry/browser';
import { init, captureMessage, captureException } from '@sentry/browser';

I will get the following error in the browser:

misc.js:3 Uncaught ReferenceError: require is not defined
    at Object../node_modules/@sentry/utils/misc.js (misc.js:3)
    at __webpack_require__ (bootstrap:63)
    at Module../node_modules/@sentry/hub/esm/scope.js (scope.js:1)
    at __webpack_require__ (bootstrap:63)
    at Module../node_modules/@sentry/hub/esm/index.js (index.js:1)
    at __webpack_require__ (bootstrap:63)
    at Module../node_modules/@sentry/minimal/esm/index.js (index.js:1)
    at __webpack_require__ (bootstrap:63)
    at Module../node_modules/@sentry/core/esm/index.js (index.js:1)
    at __webpack_require__ (bootstrap:63)

Because in misc.js a require() statement is being done. All other files seem to correctly use import and export. Do you think this is an error on our side due to our Webpack configuration, or is this an issue in Sentry?

I am thinking of the latter, because the esm files correctly use import/export except when they import the /utils/misc.js file.

@wsloth
Copy link
Author

wsloth commented Apr 5, 2019

Wow, thank you for picking up the issue so fast! Looking forward to having this released so we can immediately start using it 😄 ❤️

@HazAT
Copy link
Member

HazAT commented Apr 5, 2019

I will make a release later today, stay tuned!
Thanks for reporting 💯

@baltuonis
Copy link

Same problem on ` "@sentry/browser": "^5.5.0",

"parcel-bundler": "^1.12.3",
"typescript": "^3.5.2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants