__dirname


当前模块的目录名称。这与__filenamepath.dirname()相同。

【The directory name of the current module. This is the same as the path.dirname() of the __filename.】

示例:从 /Users/mjr 运行 node example.js

【Example: running node example.js from /Users/mjr

console.log(__dirname);
// Prints: /Users/mjr
console.log(path.dirname(__filename));
// Prints: /Users/mjr