Hope you all are doing well and I’ll explain how I made a favicon show up successfully on my browser after an hour of search.
Currently, I am working on building a node app using express with restful service. So this post will explain how I made a favicon show up in the browser using the features of the express framework.
Initially, I want to brag a bit about the express framework. It is a lightweight node.js web application framework which is currently holding huge recommendation from the node.js community if one wants to build a web app presenting rest services. It has 25750 stars and 4800 forks as I write this.
Some useful resources for express framework
GitHub : Link
How I have done it
- Initially, I recommend you to take the code generated by the express generator module (google how u can get the express generator installed locally )
- If u generate the code using express generator then all u have to do is jus uncomment the following code which u get by default.
in the above line we use path and favicon dependencies which come by default if u have used the express generator.
if not you have to do the following
var path = require(‘path‘);
var favicon = require(‘serve-favicon‘);
you’ll have to place the favicon.ico file in the public/images directory 🙂
For any queries ask in #express , #nodejs channel via IRC. I am sure they’ll help you.