Open Nani2777 opened 1 year ago
i'am facing the same issue, but now already fixed it. this is my setup:
const viewpath = path.join(__dirname, './views')
const nnjk = require('nunjucks')
nnjk.configure(viewpath, {
autoescape: true,
express: app,
})
app.set('views', viewpath)
app.set('view engine', 'html')
just set your view path equal to express views hope this would help,
I have been trying to run my demo site and was able to run it successfully from the current directory but after configuring the service file in systemd was unable to run it.
`nunjucks.configure("views", { autoescape: true, express: app });
app.set('views', path.join(__dirname, 'views')); app.set("view engine", "nunjucks");
app.use("/public", express.static(dirname + "/public")); app.use("/", express.static(dirname + "/"));
app.get(["/","/index","/index.html"], (req, res) => { data.base_file = __dirname + '/views/base_file.njk'; res.render(__dirname + "/views/index.njk", data); })`
And Directory structure as follows![Screenshot from 2023-01-20 14-28-07](https://user-images.githubusercontent.com/8339263/213656056-9c6b6b44-ae9a-4f99-813c-7ce41693062b.png)
Below is the Error Screenshot![Screenshot from 2023-01-20 14-37-06](https://user-images.githubusercontent.com/8339263/213657469-3f2efac6-2793-4c91-801b-e380a63a3f15.png)
Can someone please help