I've just started using eslint. I initialized it and started fixing problems it pointed out. One problem, however, it shouldn't complain about:
const data = fs.readFileSync(path.join(__dirname, _FILENAME));
The error is:
error '__dirname' is not defined
I did some searching and found that when you add --experimental
to the node command that __dirname
is not defined. This, however, isn't the case for me. I'm not running node with the --experimental
flag.
See these questions:
process.cwd()
instead – Institutorprocess.cwd()
give the current working directory of the process? Sometimes you want the path of the (possibly included or required) file instead. – Mccormac