问题
I wish to store the directory my node.js script has been run from in a variable, how would I do this?
The fs module documentation doesn't seem to hold an answer to this.
回答1:
What you are looking for is __dirname
: http://nodejs.org/docs/latest/api/globals.html#globals_dirname
来源:https://stackoverflow.com/questions/22213792/how-do-i-find-the-current-working-directory-of-a-node-js-program-to-store-in-a-v