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

Since the @amplitude/session-replay-browser 1.6.1 update, nextjs fails to build due to Error [ERR_REQUIRE_ESM]. #784

Closed
jylee9937 opened this issue Jun 19, 2024 · 7 comments
Assignees
Labels
bug Something isn't working v1.x

Comments

@jylee9937
Copy link

jylee9937 commented Jun 19, 2024

Expected Behavior

nextjs project build

Current Behavior

An error is occurring. The error happens regardless of the version, and it has been occurring since @amplitude/plugin-session-replay-browser version 1.6.1. Downgrading to other versions doesn't resolve the issue. But remove that, I can build nextjs project.

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
info  - Linting and checking validity of types  
info  - Creating an optimized production build  
info  - Compiled successfully
info  - Collecting page data .Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/a123123/WebstormProjects/Client-HomePage-Next/node_modules/@medv/finder/finder.js from /Users/a123123/WebstormProjects/Client-HomePage-Next/node_modules/@amplitude/session-replay-browser/lib/cjs/hooks/click.js not supported.
Instead change the require of finder.js in /Users/a123123/WebstormProjects/Client-HomePage-Next/node_modules/@amplitude/session-replay-browser/lib/cjs/hooks/click.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/a123123/WebstormProjects/Client-HomePage-Next/node_modules/@amplitude/session-replay-browser/lib/cjs/hooks/click.js:6:16) {
  code: 'ERR_REQUIRE_ESM'
}

Steps to Reproduce

  1. make nextjs project
  2. setup @amplitude/plugin-session-replay-browser in _app.tsx
  3. necxt build

Environment

  • JS SDK Version: Node 20.10.0 + nextjs 13.1.1 + @amplitude/analytics-browser 2.6.2
  • Installation Method: Yarn
  • Browser and Version: n/a
@jylee9937 jylee9937 added the bug Something isn't working label Jun 19, 2024
@purepetfood
Copy link

Same issue here

@anders2410
Copy link

anders2410 commented Jun 20, 2024

We are also experiencing the same issues using Next.js 14.2.3

@sharath-sb
Copy link

Same here

1 similar comment
@lok225
Copy link

lok225 commented Jun 24, 2024

Same here

@lewgordon-amplitude
Copy link

Hey all. Thanks for reporting this. We're looking into it.

@lewgordon-amplitude
Copy link

I just published a new version @amplitude/[email protected]. Does this fix the issue?

@jylee9937
Copy link
Author

Hi Lew Gordon, Your help is greatly appreciated, and everything is working perfectly now.
Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v1.x
Projects
None yet
Development

No branches or pull requests

6 participants