Skip to content Skip to sidebar Skip to footer

How To Include A Js Script In A Ejs File, Nodejs App?

I'm doing the nodeJS tuto on openclassroom. I use the template engine ejs. I try to run a simple JS script but I can't. Here is my app structure: App_toDoList/ │ ├──app.js

Solution 1:

Ok I find my mistake. I have never stated to my node server where are the static files. I add this line app.use(express.static('public')); above the session line. And I create a folder '/public' next to app.js

This way, my server sends file when ejstemplate require image, CSS, or JS

Post a Comment for "How To Include A Js Script In A Ejs File, Nodejs App?"