sindresorhus / slugify

Slugify a string
MIT License
2.56k stars 81 forks source link

Error [ERR_REQUIRE_ESM]: require() of ES Module #67

Closed leosin closed 2 years ago

leosin commented 2 years ago

Error [ERR_REQUIRE_ESM]: require() of ES Module

import Slugify from '@sindresorhus/slugify'

image

node_modules/@sindresorhus/slugify/index.js from .../vite.config.ts not supported.

Am I doing something wrong?

https://github.com/jeremys/uslug

i use this plugin is ok slugify: (s: string) => uslug(s),

sindresorhus commented 2 years ago

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

leosin commented 2 years ago

Thank you very much, I will read it carefully

krazyjakee commented 2 years ago

but this doesn't actually resolve the issue. This is a library that could be used in .js configurations which cannot be configured to run like a module or be precompiled. I work with thousands of npm libraries, this is the only one which stubbornly misunderstands the current ecosystem.

lud commented 1 year ago

Can this be used with eleventy?

nezort11 commented 1 year ago

Just use this package https://github.com/simov/slugify instead of this, same API. it's not worth all the hassle with ESM modules for a single package