From the node manual I see that I can get the directory of a file with __dirname, but from the REPL this seems to be undefined. Is this a misunderstanding on my
I was also trying to join my path using path.join(__dirname, 'access.log') but it was throwing the same error.
Here is how I fixed it:
I first imported the path package and declared a variable named __dirname, then called the resolve path method.
In CommonJS
var path = require("path");
var __dirname = path.resolve();
In ES6+
import path from 'path';
const __dirname = path.resolve();
Happy coding.......