@@TheCodingTrain I GOT THE JOB! Will start tomorrow. THANK YOU THANK YOU SO MUCH for all the wonderful videos. You're not helping just me but everyone that wants to learn!
For those that are not able to get the ellipse at 10:40 try editing your index.html file by replacing the script lines (not the one with sketch.js but the other ones) to include "libraries/" at the front of the js file in the src attribute. i.e. change to repeat with the other lines.
My head is spinning with those amazing 4 lines of server code. "express" is a function name so we have express(), but what it function name dot then, express.static(..)? I guess the 4 strings of "express" mean 3 different things. The last one, or even the 2nd one which is quoted, might be the module name.
*I'VE FINALLY FIGURED OUT HOW TO DO THIS FOR WINDOWS CMD* I hope this works for you as well: I'm assuming you're already in your project directory Instead of "--save" try "-g" at the end, so you type "npm install socket.io -g" (or "npm install express -g" for express) I do not fully understand, but apparently windows does not like "--save" Also when you install socket.io or express, run the command "npm list" to see all the installed dependencies or "npm list socket.io"/"npm list express" to see the specific dependency Now, if all went well you see a message like this: " `-- socket.io@2.3.0", in yellow text But if you see " `-- (empty)" or some sort of error, you type another command: "npm install -g". This was the command that worked for me. From what I understood this automatically installs all dependencies (again?). After this try the list command again and hopefully it works for you too. ALSO: The install commands did not automatically added the dependencies to the package.json file for me so if it that's the case for you too, add this yourself: "dependencies": { "express": "^4.17.1", "socket.io": "^2.3.0" } (you may have to change the version numbers) I'm also posting this comment under the next video so everyone can see this Hope it helps!
so I got stuck because I couldnt get javascript to draw stuff when I opened the html page through localhost:3000 (using server.js and express) I later realized all the p5 files (p5.js, p5.min.js etc...) also need to be in the public folder, along with the sketch file, for it to actually draw stuff
The file structure is something like this for me... Project folder > Public - having p5 files > directory having sketch files. This is the only way my p5 sketch runs when loaded. The sketch does not run when the sketch files are in the same directory as the p5 files... They have to be in the parent directory and then the sketch files in a directory inside that.
oh men, i finally i made my first webpage with p5.js hosted by node.js. thank u sir. if you were my professor in college it will not be boring and dull.enjoy ur video
For anyone not using P5.js At 10:40 my javascript file doesnt directly run like his does, i have to go localhost:3000/myJsFile.js but yea - it serves it
Linking to the js file should just show the js source code. I think you meant the html file, which I had to do. The reason for this I realized is that if the file is not called index.html, then it must be explicitly given after "localhost:3000".
Please help. Tried this code. Doesn't serve anything. but the error message in firefox says localhost:3000/server.js” was blocked due to MIME type mismatch (X-Content-Type-Options: nosniff). any help .. thanks !!
If I use require() in my p5 sketch.js file in the public folder I get an error message in the console saying require is not defined. Is there a way to use require() inside the sketch.js file?
Thank you Daniel. Working fine: I saved a model.json but then could not load it in the browser. Running well from localhost... The code can recognize my daughter and my wife by now. will improve including myself and the cats.
Or Heroku is a common (and free) Node host, too. You could also just run the server on your own computer and give out your IP address, and then anyone can connect to it that way. Or get a domain name and point it to your IP address, then anyone can just use the domain. Basically, as long as the server application is running, it *is* live on the internet; you just have to let people know the address of the computer the server is on :)
@@IceMetalPunk Excuse me but can u elaborate more on how i can get my node.js app to the internet if i already have a domain name ...like how do i upload my app to the domain ?
@@aaryandhakal4691 You should just need to add an A record with your IP and the port number, and it should work, as long as the node app is running. (You may have to port forward)
it works but then when I update my script.js file it won't update in the browser. Even if I ctrl C in the command line and then node server.js in command line and then refresh browser
when I cut and paste the html , css and js files etc into the 'public' folder, I didn't close those files from my text editor. Basically the files in the old directory weren't deleted - I had actually just created copies of them. So when I was editing my html and js files in my text editor, I was actually editing the old versions in the old directory. I closed them and then opened the files that were in the new directory. Now I can change my js file etc and the changes are reflected when I refresh my browser.
Does anyone know why I am getting the "Cannot GET /" error on localhost:3000 but my sketch is showing locally if i bring it up and open it as regular URL(saving the html file and then double clicking it)? I have tried using multiple ports as well
wow, this is like everything anyone could ever want in life in 5 lines xD actually it's the other video that needs a reference to this one, this is much more clear about the setup being of the actual sketch folder. the other lead me onto i was setting up the computer and node more locally to be an ongoing one time thing thing like adding drivers to windows, not running the setup and adding express sketch and tailoring up each server sketch. i was apparently just running gobbley goo thru node that had nothing that meant anything, now will be going back to where i just left off on that one now that they both work lol very cool
I have a problem with finding 'express', while using cmd on Windows. I have used all the instructions from expressjs.com/en/starter/installing.html and I have already installed node.js (it works). In server.js file there is a problem with uploading 'express' too. Do you know, why I sth like that happens?
Would you mind asking at discourse.processing.org/! It's a better platform for Processing and p5.js related code questions. You can share code there easily! Feel free to link from here to your post.