How to locate a parent folder?

How am I supposed to go back up 1 level to find a file?

I was trying code bellow but It’s not working

app.get('/', (req, res) => {
  res.sendFile(__dirname + '../client-side/public/index.html');

This is my folder structure

enter image description here

Trying to go public folder under client-side folder


You are using + which essentially outputs this path:


Try using path module:

const path = require("path")

app.get('/', (req, res) => {
  res.sendFile(path.join(__dirname, '../client-side/public/index.html'));

You can read more about path.join() in the documentation