How to go up using __dirname in the folder hierarchy
My app structure is:
/app
/css
/js
..
/script
/server.js
I'm trying to use __dirname to point to /app folder when using
app.use(express.static( __dirname + '/app'));
I dont realy know what to search for in the web, please help.
Solution 1:
if you're in server.js then you mean
app.use(express.static( __dirname + '/../app'));
Solution 2:
You can use path module for that.
The path module provides utilities for working with file and directory paths.
const path = require('path');
app.use(express.static(path.join(__dirname, '..', 'app')));