Counter.js not working on live site (Vercel)
So I just deployed my newest project with Vercel and I'm using the Counter.js library, but I come to an issue, where if I'm viewing the project with Live Server (VS Code), it works, and the live site (Vercel) doesn't work.
Here's the link to the source code - https://github.com/GeorgeDash/xurya (I left the node_modules visible on purpose, bc the issue might be from there) - and here's a video with the issue seen:
31 Replies
this really isn't a hard effect to make
i would really just coded it in js on my own than depend on a dependency
I see.
I just don't know almost any JS and the tutorials on the internet are kinda long.
So that's why I went with this option.
But since it doesn't work, I really may have to do it myself.
you really shouldn't be checking node_modules into git
I know - that's why I did it on purpose.
I was going to add the .gitignore file anyway.
This error should give a hint as to why it doesn't work:
Oooh, look, I didn't think of that.
if you click that link, the file 404s, so it's not available where the browser is told to expect it
I just checked and I got this.
Why it does it like that, though?
normally, you'd use a build step using vite or something similar and then deploy the built files rather than just dumping the whole project including nodemodules on vercel, but in this case you can probably just copy/paste the countUp.min.js file to somewhere local and reference where it is from your code
Aah, so in the js folder I have, for example.
Right?
but it honestly looks like you're leaping three steps ahead of where you're at. did you put those files in the build folder directly?
Which files?
From the counter.js?
like the JS folder and images and stuff
Yes, I put them in the build folder directly.
hmm, I'd take a step back and follow a quick vite tutorial first. Build folders shouldn't be written to manually
Here's my file structure.
I don't use it - I create my websites for deisgn purposes only.
So I just dont' have the need of using Vite.
š
you kinda need to use a bundler if you're going to start including shit from node_modules
Can this work?
Instead of doing this?
š¤·
worth a shot at least
OK, I'll try.
it won't work for everything, but this likely doesn't have any supporting files
And I'll let you know if it works.
you're making things unnecessarily complicated though, especially if you're going to use a second or third library
i would probably recommend coding this particular counting part on your own
GitHub
counter.js/ at master Ā· tombruijn/counter.js
A simple number counter in JavaScript as a jQuery plugin. - tombruijn/counter.js
This is the library, @Jochem.
all u need to know is how to update dom elements and setInterval()
and cancelInterval()
OK, I will look up a tutorial!
Thanks!
@Jochem It actually worked with copying the file and saving it locally.
Thanks for your help!
And sorry for pinging you again!
u can create your own function called counter() that takes 4 arguments