Node / Express Render Views

I am trying to deploy an express app using EJS. I am deploying directly from this Github repository:

isaacmaddox/barricadelawnandlanscape (github.com)

When I run the app using netlify dev it works as expected. However, when it is deployed to Netlify, I get this error:

Error: Failed to lookup view "form" in views directory "page_views"
    at Function.render (/var/task/node_modules/express/lib/application.js:597:17)
    at ServerResponse.render (/var/task/node_modules/express/lib/response.js:1048:7)
    at /var/task/netlify/functions/index.js:36:7
    at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)
    at next (/var/task/node_modules/express/lib/router/route.js:149:13)
    at csrf (/var/task/node_modules/csurf/index.js:117:5)
    at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)
    at next (/var/task/node_modules/express/lib/router/route.js:149:13)
    at Route.dispatch (/var/task/node_modules/express/lib/router/route.js:119:3)
    at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)

What am I doing wrong here?

@isaacodes What you’re deploying appears to be along the lines of:

Since express on Netlify is run via Serverless Functions, I’d imagine the issue you’re running into is that you’re trying to load the page_views/form.ejs file at runtime and it won’t have been bundled into the function deployment.

You will likely need to leverage included_files see:

https://docs.netlify.com/functions/optional-configuration/#bundle

This worked for me! Thank you so much for your help :slight_smile: