glide icon indicating copy to clipboard operation
glide copied to clipboard

ERR_REQUIRE_ESM on new version

Open corioste opened this issue 2 years ago • 8 comments

Got this version after updating the package to 3.6.0

glide.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename glide.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/cr1sg/Projects/ReactProjects/site/packages/landing/node_modules/@glidejs/glide/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at Object.UbIB (/home/cr1sg/Projects/ReactProjects/site/packages/landing/.next/server/pages/index.js:6664:18)
    at __webpack_require__ (/home/cr1sg/Projects/ReactProjects/site/packages/landing/.next/server/pages/index.js:23:31)
    at Module.RXBc (/home/cr1sg/Projects/ReactProjects/site/packages/landing/.next/server/pages/index.js:3435:14)
    at __webpack_require__ (/home/cr1sg/Projects/ReactProjects/site/packages/landing/.next/server/pages/index.js:23:31)
    at Object.3 (/home/cr1sg/Projects/ReactProjects/site/packages/landing/.next/server/pages/index.js:269:18)
    at __webpack_require__ (/home/cr1sg/Projects/ReactProjects/site/packages/landing/.next/server/pages/index.js:23:31)
    at /home/cr1sg/Projects/ReactProjects/site/packages/landing/.next/server/pages/index.js:91:18
    at Object.<anonymous> (/home/cr1sg/Projects/ReactProjects/site/packages/landing/.next/server/pages/index.js:94:10)
    at requirePage (/home/cr1sg/Projects/ReactProjects/site/packages/landing/node_modules/next/dist/next-server/server/require.js:1:1519)
    at loadComponents (/home/cr1sg/Projects/ReactProjects/site/packages/landing/node_modules/next/dist/next-server/server/load-components.js:1:1442)
    at async /home/cr1sg/Projects/ReactProjects/site/packages/landing/node_modules/next/dist/build/utils.js:23:2348
    at async Span.traceAsyncFn (/home/cr1sg/Projects/ReactProjects/site/packages/landing/node_modules/next/dist/telemetry/trace/trace.js:6:584) {
  type: 'Error',
  code: 'ERR_REQUIRE_ESM'
}

corioste avatar Oct 11 '22 02:10 corioste

I am seeing this too

mariaRomeroiTech avatar Nov 02 '22 10:11 mariaRomeroiTech

any updates?

zolzaya avatar Aug 11 '23 04:08 zolzaya

Same.

EDIT: Downgrading to 3.5.2 fixed the issue.

dessalines avatar Oct 29 '23 17:10 dessalines

Am I right to assume that the issue comes from NextJS? If so, was an issue created there?

ericmorand avatar Oct 29 '23 19:10 ericmorand

Any webpack project.

dessalines avatar Oct 29 '23 23:10 dessalines

There is no such thing as a webpack project - it is nonsensical. Do you mean that the issue appears when you bundle your code with webpack? If so, did you open an issue in their repository?

ericmorand avatar Oct 29 '23 23:10 ericmorand

There is no such thing as a webpack project - it is nonsensical.

I don't want to argue semantics, there are lots of projects that use webpack.

If so, did you open an issue in their repository?

No because this is a glide-specific issue; I have many other dependencies that are being handled fine, including a downgraded version of this one. You need to remove type: module from the package json for this to work with both commonjs and esm projects again.

dessalines avatar Oct 30 '23 19:10 dessalines

Hi Guys,

I am facing this similar issue in my Next Js application when i try upgrade the glide package to v3.6.0 from v3.5.2 . By changing the node modules directly as suggested would be a good option for local but this may not be shipped to the production as the node modules aren't ignored while pushing to remote. Is there any other workaround that could resolve this issue to upgrade glidejs? @ericmorand @dessalines @mariaRomeroiTech @zolzaya Any help would be much appreciated!!

VigneshElangovan5 avatar Jun 18 '24 15:06 VigneshElangovan5