from doc for path.resolve:
The resulting path is normalized and trailing slashes are removed unless the path is resolved to the root directory.
But path.join keeps trailing slashes
So
__dirname = '/';
path.join(__dirname, 'foo/'); // '/foo/'
path.resolve(__dirname, 'foo/'); // '/foo'