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.
转载于:https://stackoverflow.com/questions/8131344/what-is-the-difference-between-dirname-and-in-node-js