gtgalone / react-quilljs

React Hook Wrapper for Quill, powerful rich text editor.
https://www.npmjs.com/package/react-quilljs
MIT License
248 stars 28 forks source link

ReferenceError: require is not defined #41

Closed devravinder closed 2 years ago

devravinder commented 2 years ago

I got this error when I run the build command.

I'm using: Chrome: 97v React: 12.0.2 Typescript: 4..4.4.

I fixed this issue by replacing 'require' with 'import' in the below files /lib/index.js /esm/index.js

after this, I'm not getting this error.

Thank you

gtgalone commented 2 years ago

@devravinder Thank you for using.

Unfortunately You cannot use this package.

React v12 is not support React Hooks.

This package is React Hooks.

So you can use https://github.com/zenoamaro/react-quill instead.

devravinder commented 2 years ago

Sorry,

We are using React v17.0.2 not 12.0.2. I entered it wrong, I didn't check even before creating the issue. Sorry for that.

We are using Chrome: 97v React: 17.0.2 Typescript: 4..4.4.

and also we are using Vite v2.7.2, which is internally using Rollupjs to bundle. So while creating a bundle file, I was getting the above-mentioned error. But in local development, it is working fine.

As I mentioned earlier, I fixed this error in my local package, by replacing 'require' with 'import', now it is working fine.

But your package helped us to build some features in our app, thank you for your support.