How can I include css files using node, express, and ejs?

前端 未结 11 850
执念已碎
执念已碎 2020-12-01 01:37

I\'m trying to follow the instructions to https://stackoverflow.com/a/18633827/2063561, but I still can\'t get my styles.css to load.

From app.js

ap         


        
11条回答
  •  盖世英雄少女心
    2020-12-01 02:17

    Use in your main .js file:

    app.use('/css',express.static(__dirname +'/css'));
    

    use in you main .html file:

    
    

    The reason you getting an error because you are using a comma instead of a concat + after __dirname.

提交回复
热议问题