Serve JavaScript client side in Express.js application

I recently started building my first Node.js application using Express. I used the latest Express generator to create a skeletal application, and I successfully created several different layouts using Jade and CSS - all this works great.

However, I cannot get JS to work on the client side. In my shared folder, I have a separate front-end JS file, and the only thing it contains is a warning (for testing purposes only). I can successfully navigate to the file in the browser and I am not getting any console errors, however the warning never fires. What am I doing wrong?

+4
source share
1 answer

To solve this problem, I had to change the link link to the script link in my HTML. I also had to ensure that I served static files in Express.

http://expressjs.com/starter/static-files.html

+2
source

All Articles