Maybe this explains:
__dirname
is an environment variable that tells you the absolute path of the directory containing the currently executing file.
Node.js __dirname Variable - GeeksforGeeks
It appears node.js creates the temporary file in /private/var/folders/vl/x6z6g6y54gvg60cxn85jgnj80000gn/T
and then executes it?
I'm confused by the difference between the pwd
in Shell and the __dirname
in node.js.
This will also show the root directory:
The process.cwd() method is an inbuilt application programming interface of the process module which is used to get the current working directory of the node.js process.
Node process.cwd() Method - GeeksforGeeks
I thought __dirname
would point to the same root directory.
If I use the following, I'll also get the root directory:
The path.resolve() method is used to resolve a sequence of path-segments to an absolute path. It works by processing the sequence of paths from right to left, prepending each of the paths until the absolute path is created. The resulting path is normalized and trailing slashes are removed as required.
If no path segments are given as parameters, then the absolute path of the current working directory is used.
Node path.resolve() Method - GeeksforGeeks
Anyway, if nothing can be done, that's fine. I'll create a file in folder and execute it. Then __dirname
will show the expected the directory of the file.