path.dirname(path)


path.dirname() 方法返回 path 的目录名,类似于 Unix dirname 命令。 尾随的目录分隔符被忽略,见 path.sep

path.dirname('/foo/bar/baz/asdf/quux');
// 返回: '/foo/bar/baz/asdf'

如果 path 不是字符串,则抛出 TypeError

The path.dirname() method returns the directory name of a path, similar to the Unix dirname command. Trailing directory separators are ignored, see path.sep.

path.dirname('/foo/bar/baz/asdf/quux');
// Returns: '/foo/bar/baz/asdf'

A TypeError is thrown if path is not a string.