How to add a 404 Error Page in the Express ?
Express.js is a powerful framework for node.js. One of the main advantages of this framework is defining different routes or middleware to handle the client’s different incoming requests. In this article, we will discuss how to add a 404 error page i.e not found using the express server. 404 is the status code which means not found in the server.
Installing module: Install the required module using the following command.
npm install express
Project structure: It will look like this.
Run the index.js file using the below command:
Output: Now open your browser and go to http://localhost:3000/, the server will respond no page found.
My Personal Notes arrow_drop_up
Please Login to comment...