home ν app//project logical directory ├routes ├src └app.js Public//Static File Directory └node_modules
If I need to define the path of the template static file, I need to define it like this:
How can absolute paths be used? Use
process.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