color-js / color.js

Color conversion & manipulation library by the editors of the CSS Color specifications
https://colorjs.io
MIT License
1.93k stars 81 forks source link

Closest Named Color app doesn't work when ran locally #262

Closed P-Star7 closed 1 year ago

P-Star7 commented 1 year ago

I was trying to reverse-engineer this great app for my own purposes, so I downloaded the main color.js branch's source code. But even when unmodified, running the index.html inside the "apps/named" folder results in this: image Am I doing something wrong?

LeaVerou commented 1 year ago

It's hard to figure out what's going on from that description. Does the console include any error messages? Are you running it from localhost or file://?

facelessuser commented 1 year ago

You can't just open the HTML. For best results, you need to run a simple HTML server to get the site up and running locally.

Try installing a simple HTTP server:

 $ npm install http-server -g

And then run the server:

$ http-server

You'll be able to navigate the whole site as seen below, though you could configure the port to something else if you want:

http://localhost:8080/
Screenshot 2022-12-25 at 12 22 01 PM
P-Star7 commented 1 year ago

Where do I run these commands? I'm doing them in the colorjs main folder and I keep getting a module not found error, even though I have node.js/npm and color.js installed in that folder, I believe. I'm using cmd for Windows 10 x64 - the shortcut that Node.js installs for you - if that helps.

facelessuser commented 1 year ago

@P-Star7 I do them right in the main directory of the repository.

npm install http-server -g should install the http-server module globally. Then it should be accessible anywhere.

I will admit though that I don't normally do this in Windows (I'm on macOS) so I'm not sure if there are some Windows specific considerations that I'm missing.

I'm also not sure if the authors of color.js use a different way to run and test their site, this is just what I do on the occasions when I contribute to this project.

P-Star7 commented 1 year ago

Aha! It now works, I forgot to install it globally before running http-server. I installed it globally afterwards, but never tried http-server again, only "node http-server". Just running http-server did the trick. Thanks!

P-Star7 commented 1 year ago

That's odd... I spoke too soon. It indeed runs on localhost now, but still with the result in the OP. All the src dependencies in this demo's index.js (index.js and keywords.js) are where they SHOULD be.

P-Star7 commented 1 year ago

Okay, now it does. Augh...

LeaVerou commented 1 year ago

I just enabled Discussions on this repo, since it's much more suitable for these kinds of things (troubleshooting as opposed to a bug report). I will transfer this to that section now.