rexxar rexxar - 2 months ago 8
HTML Question

Public directory not found (404) ExpressJS and Jade

I already serve the static files using this.

app.use(express.static(path.join(__dirname, 'public')));


This is my index.jade sample

// jQuery
script(src='public/js/jquery.min.js')
// jQuery Easing
script(src='public/js/jquery.easing.1.3.js')
// Bootstrap
script(src='public/js/bootstrap.min.js')
// Waypoints
script(src='public/js/jquery.waypoints.min.js')
// Stellar Parallax
script(src='public/js/jquery.stellar.min.js')
// Counter
script(src='public/js/jquery.countTo.js')
// Magnific Popup
script(src='public/js/jquery.magnific-popup.min.js')
script(src='public/js/magnific-popup-options.js')
// Google Map
script(src='https://maps.googleapis.com/maps/api/js?key=AIzaSyCefOgb1ZWqYtj7raVSmN4PL2WkTrc-KyA&sensor=false')
script(src='public/js/google_map.js')
// For demo purposes only styleswitcher ( You may delete this anytime )
script(src='public/js/jquery.style.switcher.js')


Here is my structure.

enter image description here

Here is the error on my console.

enter image description here

Can anyone help me identify the problem here? That would be so much appreciated.

Answer

script(src='/js/jquery.min.js') is enough. You don't need to specify public in the URLs.

Comments