Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: util.inherits is not a function #29

Closed
ralphvirtucio opened this issue Oct 26, 2023 · 3 comments
Closed

Uncaught TypeError: util.inherits is not a function #29

ralphvirtucio opened this issue Oct 26, 2023 · 3 comments
Labels
question Further information is requested

Comments

@ralphvirtucio
Copy link

Hi there,

I'd like to report an issue. After installing 'heic-convert' in my Vue project and attempting to import it into my components, I encountered the following error: "Uncaught TypeError: util.inherits is not a function." Could you please provide insights into the cause of this error?

@catdad catdad added the question Further information is requested label Nov 9, 2023
@catdad
Copy link
Member

catdad commented Nov 9, 2023

No immediate guesses. I don't have a readily available vue project. Do you have a minimal repro example for this?

@vladimir-djokic-quantox
Copy link

vladimir-djokic-quantox commented Nov 15, 2023

I have stumbled upon this issue as well in a React project. You can view the demo here https://stackblitz.com/edit/vitejs-vite-cqulcz?file=src%2Fcomponents%2FUploader.tsx

Screenshot 2023-11-15 at 14 43 44

@catdad
Copy link
Member

catdad commented Nov 30, 2023

So this is actually a vite issue, and has nothing to do with what framework vite is building. Googling this error easily finds a whole slew of solutions, likely the best one being just using the vite-plugin-node-polyfills plugin.

However, I can do one better. pngjs and jpeg-js are used to encode the result images, and are both decently sized modules. However, when building a client-side application, they really are not needed, since all browsers already have built-in png and jpeg encoders. So in version 2.1.0, I made these encoders optional, and when building a client-side application, you can require('heic-convert/browser') to use the browser's built-in encoders and leave pngjs and jpeg-js out of your final bundle. See #33 for more if you are curious.

@catdad catdad closed this as completed Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants