What is the difference between __dirname and ./ in node.js?

When programming in Node.js and referencing files that are located somewhere in relation to your current directory, is there any reason to use the __dirname variable instead of just a regular ./? I’ve been using ./ thus far in my code and just discovered the existence of __dirname, and essentially want to know whether it would be smart to convert my ./’s to that, and if so, why that would be a smart idea.

2 s
2

Leave a Comment