Js path problem

  node.js, question

Project structure

 ν app//project logical directory
 Public//Static File Directory

If I need to define the path of the template static file, I need to define it like this:

app.use(express.static(path.join(__dirname, '../public')));

How can absolute paths be used? Use__dirnameAndprocess.cwd()None of these variable methods can achieve results.
Is there any way to get the root directory of the project and use it globally?

Does not work means that the static directory is wrong? Then replace it with:

//suppose this code is written in the home/app directory.
 app.use(express.static(path.resolve(__dirname, '..', 'public')));

It’s really useless to make it into a whole. Stop it