webserver – How to Include EJS Template Files in a Node.js Executable
I’m developing a Node.js web application using Express and EJS as the view engine. My goal is to create a single executable file that I can run on my webserver without needing to copy any additional folders or files.
Here’s my setup:
- Node.js application using Express
- EJS templates in a view folder
- Using pkg to bundle the application into a single .exe file
My Express setup looks like this:
path = require('path');
const express = require('express');
const app = express();
app.set('views', path.join(__dirname, 'view'));
app.set('view engine', 'ejs');
// Routes
app.get("https://stackoverflow.com/", (req, res) => {
res.render("myfile");
});
When I copy only the .exe file to my webserver and try to run it, I get the following error:
Error: Failed to lookup view "myfile" in views directory "C:\snapshot\WebApp\build\view"
How can I correctly include the myfile.ejs file in my executable using pkg?
Read more here: Source link
