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

Problem with using Vite + Vue #48

Open
6474131 opened this issue Mar 31, 2023 · 5 comments
Open

Problem with using Vite + Vue #48

6474131 opened this issue Mar 31, 2023 · 5 comments

Comments

@6474131
Copy link

6474131 commented Mar 31, 2023

image

I get this error and I'm not really sure how to fix it, although it seems similar to #37. For reference all I'm doing is importing gif-frames, I'm not doing anything else at the moment.

@liangtian123
Copy link

me too

@benwiley4000
Copy link
Owner

My guess is this is due to the dependencies (get pixels, save pixels) relying on node.js packages built into browserify, webpack etc and perhaps they're not supported by vite. Really wild guess, I'm not sure.

@liangtian123
Copy link

The following information is key to resolving this issue:
I copied gif-frames.js into my project and then processed it

var EE = require_events().EventEmitter;
if (!EE.listenerCount)
EE.listenerCount = function(emitter, type) {
return emitter.listeners(type).length;
};

save-pixels-jpeg-js-upgrade.js?v=88a5b38b:39 Module "events" has been externalized for browser compatibility. Cannot access "events.EventEmitter" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

image

@liangtian123
Copy link

I downloaded https://unpkg.com/[email protected]/dist/gif-frames.min.js locally, put it into my project, and then introduced it in index.html, and the problem was solved

<script src="/src/js/gif-frames.min.js"></script>

Note that package.json does not need to introduce "gif-frames": "^1.0.1" again

@benwiley4000
Copy link
Owner

benwiley4000 commented Dec 18, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants