# P5.js // node server not working

**URL:** <https://discourse.processing.org/t/p5-js-node-server-not-working/4766>\
**Category:** Libraries\
**Created:** [October 23, 2018, 2:10am UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766 "2018-10-23T02:10:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [October 23, 2018, 2:10am UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/1 "2018-10-23T02:10:47Z")

</div>

[![](https://img.youtube.com/vi/bjULmG8fqc8/hqdefault.jpg "12.1: Introduction to Node - WebSockets and p5.js Tutorial") ](https://www.youtube.com/watch?v=bjULmG8fqc8&t=466s)

[![](https://img.youtube.com/vi/2hhEOGXcCvg/maxresdefault.jpg "12.2: Using Express with Node - WebSockets and p5.js Tutorial") ](https://www.youtube.com/watch?v=2hhEOGXcCvg&t=545s)

Here I thought I copied these two videos exactly and it worked all the way until this moment of the second video.

[![](https://img.youtube.com/vi/2hhEOGXcCvg/maxresdefault.jpg "12.2: Using Express with Node - WebSockets and p5.js Tutorial") ](https://www.youtube.com/watch?v=2hhEOGXcCvg&t=629)

here is what I am seeing:

 ![2018-10-22%20(1)](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/9770197eea05417e432129de5c546db2aac4d277.png)

---

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [October 23, 2018, 12:08pm UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/2 "2018-10-23T12:08:17Z")

</div>

BUMP  
Still no answers

---

<div class="post-metadata">

**Author:** ![julian2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/julian2/32/1551_2.png) [@julian2](https://discourse.processing.org/u/julian2)\
**Post date:** [October 23, 2018, 3:51pm UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/3 "2018-10-23T15:51:46Z")

</div>

Hmm, since you’re getting 404s I would check how you set up express / static content serving. If you could post your app.js or server side code that would help 🙂

Do you have something like this in your server app?:  
`app.use(express.static('public'))`

And a directory called `public`?:  
So you might have something like:

- public/p5.min.js
- public/addons/p5.dom.min.js  
Etc

I’m just stabbing in the dark here, but this might help [https://expressjs.com/en/starter/static-files.html](https://expressjs.com/en/starter/static-files.html)

---

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [October 23, 2018, 4:27pm UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/4 "2018-10-23T16:27:25Z")

</div>

[http://s000.tinyupload.com/?file\_id=98188583476515935874](http://s000.tinyupload.com/index.php?file_id=98188583476515935874)

---

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [October 23, 2018, 5:56pm UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/5 "2018-10-23T17:56:59Z")

</div>

I removed the libraries but it still did not work

---

<div class="post-metadata">

**Author:** ![julian2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/julian2/32/1551_2.png) [@julian2](https://discourse.processing.org/u/julian2)\
**Post date:** [October 23, 2018, 8:38pm UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/6 "2018-10-23T20:38:40Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/75bedaeac78de0b2b2af1c75a2b06bbc8aeb6c1b.png)

this screenshot should hopefully show everything & clear things up 🙂

more specifically, the ordering of your `app.listen()` and `app.use()` was wrong, you have to assign all the middlewares & handlers _before_ you call `app.listen()`

---

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [October 23, 2018, 9:14pm UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/7 "2018-10-23T21:14:14Z")

</div>

still some issues… getting 404’s and it says:  
Cannot Get /

---

<div class="post-metadata">

**Author:** ![bmoren](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bmoren/32/68_2.png) [@bmoren](https://discourse.processing.org/u/bmoren)\
**Post date:** [October 24, 2018, 3:43am UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/8 "2018-10-24T03:43:27Z")

</div>

are your p5js files, inside of a directory called public? (…you asked express to server out all of the files in the public folder statically)

see this file hierarchy:  
 ![38%20PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4132c2f89048291242874af5ebf10499e6f76f91.png)

---

<div class="post-metadata">

**Author:** ![codingking03](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@codingking03](https://discourse.processing.org/u/codingking03)\
**Post date:** [October 24, 2018, 3:47pm UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/9 "2018-10-24T15:47:20Z")

</div>

I would like to post the whole folder but I do not know how I do not have p5.min.js or package lock json

---

<div class="post-metadata">

**Author:** ![bmoren](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bmoren/32/68_2.png) [@bmoren](https://discourse.processing.org/u/bmoren)\
**Post date:** [October 25, 2018, 11:56pm UTC](https://discourse.processing.org/t/p5-js-node-server-not-working/4766/10 "2018-10-25T23:56:51Z")

</div>

package.lock is auto generated from NPM, you may or may not have it. It shouldn’t effect your ability to run the server.

also, you might not need the p5.min.js depending on how your project is organized.

when you boot your server in your terminal, what do you get back? do you get any errors, or does it only read “my server is running” ?

if you are getting errors, perhaps you can relay them here.
