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

Cannot destructure property 'sentryWebpackPlugin' of 'utils.loadModule(...)' as it is undefined #13665

Closed
3 tasks done
klaa97 opened this issue Sep 11, 2024 · 10 comments
Closed
3 tasks done
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@klaa97
Copy link

klaa97 commented Sep 11, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.30.0

Framework Version

Next 13.4.7

Link to Sentry event

No response

Reproduction Example/SDK Setup

I have the following versions:

  • Next 13.4.7 (but it also fails with 12.3.1)
  • Sentry 8.30.0
  • React 18.3.1

If I add the withSentryConfig to NextJS, such as this:

withSentryConfig(configWithPlugins, {
// private configs (org, project, token)
			hideSourceMaps: true,
			disableLogger: true,
		});

I get an error when building:

> Build error occurred
TypeError: Cannot destructure property 'sentryWebpackPlugin' of 'utils.loadModule(...)' as it is undefined.
    at Object.newWebpackFunction [as webpack] (/Users/project/node_modules/.pnpm/@sentry+nextjs@8.30.0_next@13.4.7+react@18.3.1/node_modules/@sentry/nextjs/build/cjs/config/webpack.js:324:15)
    at getBaseWebpackConfig (/Users/project/node_modules/.pnpm/next@13.4.7_37z3we5wden4rzgrojygioj2rq/node_modules/next/dist/build/webpack-config.js:2113:32)
    at async Promise.all (index 1)
    at async Span.traceAsyncFn (/Users/project/node_modules/.pnpm/next@13.4.7_37z3we5wden4rzgrojygioj2rq/node_modules/next/dist/trace/trace.js:103:20)
    at async webpackBuildImpl (/Users/project/node_modules/.pnpm/next@13.4.7_37z3we5wden4rzgrojygioj2rq/node_modules/next/dist/build/webpack-build/impl.js:133:21)
    at async webpackBuild (/Users/project/node_modules/.pnpm/next@13.4.7_37z3we5wden4rzgrojygioj2rq/node_modules/next/dist/build/webpack-build/index.js:137:16)
    at async /Users/project/node_modules/.pnpm/next@13.4.7_37z3we5wden4rzgrojygioj2rq/node_modules/next/dist/build/index.js:558:123
    at async Span.traceAsyncFn (/Users/project/node_modules/.pnpm/next@13.4.7_37z3we5wden4rzgrojygioj2rq/node_modules/next/dist/trace/trace.js:103:20)
    at async build (/Users/project/node_modules/.pnpm/next@13.4.7_37z3we5wden4rzgrojygioj2rq/node_modules/next/dist/build/index.js:145:29)

Steps to Reproduce

  1. Simple app with the versions I defined above
  2. If I add SentryWithConfig, it fails
  3. Otherwise, it does not

Expected Result

It succeeds the build

Actual Result

It fails the build with the error above

@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Sep 11, 2024
@chargome
Copy link
Member

hey @klaa97, thanks for reaching out!

Are you using yarn with the pnp node-linker?

@klaa97
Copy link
Author

klaa97 commented Sep 11, 2024

I am not configuring it explicitly, so I think I am using hoisted. (I am using pnpm)

@chargome
Copy link
Member

Looks like it might still be related to #13641

We'll have a look!

@ibufu
Copy link

ibufu commented Sep 12, 2024

It also failed with Next.js v14.2.8.

@ibufu
Copy link

ibufu commented Sep 12, 2024

@chargome Any workaround or suggestion?

@chargome
Copy link
Member

@ibufu if you're using pnpm you can try setting node-linker to hoisted explicitly, I did not try this myself yet though

@ibufu
Copy link

ibufu commented Sep 12, 2024

@ibufu if you're using pnpm you can try setting node-linker to hoisted explicitly, I did not try this myself yet though

Thanks! I downgraded from 8.30.0 to 7.*. It works now.

@ibufu
Copy link

ibufu commented Sep 12, 2024

I spent a whole day figuring out why the sourcemap not uploaded on v7.x.

// @sentry/nextjs/cjs/config/webpack.js
const SentryWebpackPlugin = utils.loadModule('@sentry/webpack-plugin');

Finally I found SentryWebpackPlugin was undefined. Maybe utils.loadModule doesn't work with pnpm.
So I added the following line into .npmrc then everything works well.

// .npmrc
hoist-pattern[]=*sentry*

I hope this can help people using pnpm monorepo. 🙏

@chargome
Copy link
Member

@ibufu yes this was already clarified in #13641 since we access node_modules there directly, sorry you burned so much time on this – but thanks for the pnpm workaround you provided!

@chargome
Copy link
Member

closing this in favour of #13641

duplicate of #13641

@chargome chargome closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
Archived in project
Development

No branches or pull requests

3 participants