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
glutonium
glutoniumā€¢2mo ago
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
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
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.
Jochem
Jochemā€¢2mo ago
you really shouldn't be checking node_modules into git
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
I know - that's why I did it on purpose. I was going to add the .gitignore file anyway.
Jochem
Jochemā€¢2mo ago
This error should give a hint as to why it doesn't work:
No description
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
Oooh, look, I didn't think of that.
Jochem
Jochemā€¢2mo ago
if you click that link, the file 404s, so it's not available where the browser is told to expect it
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
No description
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
I just checked and I got this. Why it does it like that, though?
Jochem
Jochemā€¢2mo ago
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
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
Aah, so in the js folder I have, for example. Right?
Jochem
Jochemā€¢2mo ago
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?
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
Which files? From the counter.js?
Jochem
Jochemā€¢2mo ago
like the JS folder and images and stuff
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
Yes, I put them in the build folder directly.
Jochem
Jochemā€¢2mo ago
hmm, I'd take a step back and follow a quick vite tutorial first. Build folders shouldn't be written to manually
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
No description
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
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. šŸ˜
Jochem
Jochemā€¢2mo ago
you kinda need to use a bundler if you're going to start including shit from node_modules
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
Can this work? Instead of doing this?
Jochem
Jochemā€¢2mo ago
šŸ¤· worth a shot at least
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
OK, I'll try.
Jochem
Jochemā€¢2mo ago
it won't work for everything, but this likely doesn't have any supporting files
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
And I'll let you know if it works.
Jochem
Jochemā€¢2mo ago
you're making things unnecessarily complicated though, especially if you're going to use a second or third library
glutonium
glutoniumā€¢2mo ago
i would probably recommend coding this particular counting part on your own
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
GitHub
counter.js/ at master Ā· tombruijn/counter.js
A simple number counter in JavaScript as a jQuery plugin. - tombruijn/counter.js
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
This is the library, @Jochem.
glutonium
glutoniumā€¢2mo ago
all u need to know is how to update dom elements and setInterval() and cancelInterval()
GeorgeCraft225
GeorgeCraft225OPā€¢2mo ago
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!
glutonium
glutoniumā€¢2mo ago
u can create your own function called counter() that takes 4 arguments
function counter(startNumber, endNumber, elementToUpdate, delta_t) {
// code
}
function counter(startNumber, endNumber, elementToUpdate, delta_t) {
// code
}
Want results from more Discord servers?
Add your server