Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

ERR_REQUIRE_ESM error within NextJS project. #18

Open
josefssonemil opened this issue Mar 27, 2023 · 6 comments
Open

ERR_REQUIRE_ESM error within NextJS project. #18

josefssonemil opened this issue Mar 27, 2023 · 6 comments

Comments

@josefssonemil
Copy link

This error pops up whenever I try to use the SEO Pane in a studio which is embedded within a NextJS project

error - Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/lodash-es/lodash.js from .../node_modules/sanity-plugin-seo-pane/dist/index.js not supported.
Instead change the require of lodash.js in .../node_modules/sanity-plugin-seo-pane/dist/index.js to a dynamic import() which is available in all CommonJS modules.

It seems as if this row in dist/index.js is the culprit:

var lodashEs = require('lodash-es'); (line 10)

I've added esmExternals: "loose" to next.config.mjs but it doesn't help. I'm using the latest versions of Next, Sanity and the plugin itself.

Help would be much appreciated :)

@Jacobfred88
Copy link

I'm having the same issue. Added esmExternals: "loose", but it's also not working!

@manishwg
Copy link

I'm also having the same issue.

@tahmeednabi
Copy link

Adding this to next.config.js fixed it for me:

/** @type {import('next').NextConfig} */
module.exports = {
  ...
  transpilePackages: [
    "sanity-plugin-seo-pane",
    "lodash-es",
    "yoastseo",
    "@yoast",
  ],
};

@ollebergkvist
Copy link

ollebergkvist commented Jul 23, 2023

Adding this to next.config.js fixed it for me:

/** @type {import('next').NextConfig} */
module.exports = {
  ...
  transpilePackages: [
    "sanity-plugin-seo-pane",
    "lodash-es",
    "yoastseo",
    "@yoast",
  ],
};

Did not work for me :/

@DanielHirunrusme
Copy link

  • 1

@shealan
Copy link

shealan commented Feb 3, 2024

Worked for me, thank you!

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

No branches or pull requests

7 participants