Including Javascript - path not working? Help!

Hello FCC,

My directory looks is structured like this

lib > public > scripts (dir, contains script.js file), view (dir, contains index.pug)

from index.pug i am trying to run a script located in lib > public > scripts.

To do this in with pug, I thought I could have a script tag like this:

script(type="text/javascript" src="../scripts/script.js") (go up a level from index.pug, into scripts dir and run script.js)

alternatively I thought that I could also start from the root to access script.js by going:
script(type="text/javascript" src="/lib/public/scripts/script.js")

In both cases i am getting 404 - the browser cannot find the file. Can someone explain to me what I am doing wrong?

Thank you FCC!

http://www.simplehtml.co.uk/pages/folders.html

1 Like

Hmm. I just cant get this to work. I wonder if it is something to do with my directory structure and using path() in node…

Well I figured it out. If anyone is wondering: serving static files in express

Thanks all :slight_smile:

1 Like