glidejs / glide

A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more
https://glidejs.com
MIT License
7.3k stars 771 forks source link

ERR_REQUIRE_ESM on new version #627

Open corioste opened 2 years ago

corioste commented 2 years ago

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'
}
mariaRomeroiTech commented 1 year ago

I am seeing this too

zolzaya commented 1 year ago

any updates?

dessalines commented 11 months ago

Same.

EDIT: Downgrading to 3.5.2 fixed the issue.

ericmorand commented 11 months ago

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

dessalines commented 11 months ago

Any webpack project.

ericmorand commented 11 months ago

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?

dessalines commented 11 months ago

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.

VigneshElangovan5 commented 4 months ago

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!!