How To Fix ReferenceError: __dirname is not defined

How To Fix ReferenceError: __dirname is not defined

es6 modules nodejs

I recently tried to use inside a ES module. It turns out, that I cannot. It throws an error. So let us see how To Fix ReferenceError: __dirname is not defined. For people who do not know what it is, let us first discuss what is. is a global variable in Node.js that can be used to reference the directory name of the current module. We can use and to get the name of the directory…

Source