Categories
JavaScript Answers

How to fix Error: Failed to lookup view in Node Express?

Spread the love

To fix Error: Failed to lookup view in Node Express, we should use a valid path.

For instance, we write

const path = require("path");
app.use(express.static(path.join(__dirname + "../public")));

to call express.static foplder with the path returned by path.join to get the path of the /public folder one level above __dirname to expose the folder as the static files folder.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.