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

"TypeError: mod.require is not a function" error when trying use @sentry/tracing #617

Open
dmitrykozyrenko opened this issue Nov 10, 2020 · 2 comments

Comments

@dmitrykozyrenko
Copy link

Got an error TypeError: mod.require is not a function when trying to start compiled express server than use @sentry/tracing package.

image

Error occurs when performing this function call from @sentry/utils package:

image

Any ideas how this can be fixed? Thanks in advance!

@LoicMahieu
Copy link

Fixed by exclude @sentry/node from build, ncc -e @sentry/node src/index.ts

@PaulRBerg
Copy link

PaulRBerg commented Sep 20, 2021

I've also encountered this issue with a module that is needed only when the user sets a boolean flag to true (my project is a CLI tool). Here's the source code:

if (framework) {
  const foundFramework: boolean = await hasFramework(framework);
  const foundFrameworkHandlebars: boolean = await hasFrameworkHandlebars(framework);

  if (!foundFramework || !foundFrameworkHandlebars) {
    throwFrameworkNotFoundError(framework);
  }

The hasFramework function imports the url-exist package, which is not bundled by ncc.

This wasn't an issue when I was on v0.24.1 - it started happening when I switched to v0.31.1. Is there a way to bring the old behaviour back?

Update: is this related to #756?

Update: I eventually figured it out .. the issue was not with ncc, but with the fact that I was importing an ESM package into a non-ESM project. I explained my problem in more details in WalletConnect/create-eth-app#162. Sorry for the spam.

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