12.2: Using Express with Node - WebSockets and p5.js Tutorial
Why Stack Overflow recommends it
Stack Overflow users cite it as the tutorial they followed to set up a Node, Express and p5.js project, then link it when asking follow-up questions about their setup.
Recommended by 0 people across 0 different months, 2018 to 2020.
What it is
A short Coding Train tutorial in which Daniel Shiffman adds Express.js to a Node application so it can serve static files, including a p5.js sketch, from a local server. It covers npm setup, installing Express, choosing a port, and hosting a public folder.
What people said
Cites Satyam Gaba · 2018-08 · Stack Overflow · on “Facing this error "Failed to load resource: the server responded with a status of 404 (Not Found)"on web”
I was trying to follow this tutorial [this video] . At ‘10:40’ I see the blank page in the web browser. My server is running like in the tutorial. When I checked the console of the webpage in the web browser. I saw that following errors: Error on web browser console [LINK] Server code [LINK] p5.js sketch [LINK] index.html [LINK] directory, sketch.js and index.html are in public folder [LINK] How can I fix this? This question has also been posted here [LINK] .
Cites Jon G · 2019-08 · Stack Overflow · on “How can I import matterjs as an npm module into my p5 sketch?”
I am developing a P5 sketch, that I started by following Daniel Shiffman's "Using Express with Node - WebSockets and p5.js Tutorial" ( [this video] ). I would like to utilize Matter.js physics, so I installed matterjs with npm ( npm install matterjs ). I would like to import the ./node_modules/matterjs/dist/matter.js file in my p5.js sketch, but I can't figure out the right way to do it. Here's what my file structure looks like: ./server.js ./public/ index.html sketch.js ./node_modules/ matterjs/ dist/ matter.js So far, I've tried the following: 1 . Treating the matter.js like a regular JS file and adding the relative path to it in index.html : ... <body> <script src="../node_modules/matterjs/dis
Cites ToMakPo · 2020-11 · Stack Overflow · on “Trying to get node.js app to work on cPanel”
I followed a tutorial on [this video] that shows how to make a node.js server that works with sockets. Here is the final working server.js code. var express = require('express'); var app = express() var server = app.listen(3000) app.use(express.static('public')) console.log('My sockets server is running.'); var socket = require('socket.io') var io = socket(server) io.sockets.on('connection', newConnection) function newConnection(socket) { console.log('new connection: ', socket.id) socket.on('send-msg', data => { console.log('send-msg'); socket.broadcast.emit('send-msg', data) }) } This code works when I host it on my local server ( [LINK] ). Now I am trying to get it to be online using cPanel, I