
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
path-dirname
Advanced tools
Node.js
path.dirname()ponyfill
This was needed in order to expose path.posix.dirname() on Node.js v0.10
$ npm install --save path-dirname
const pathDirname = require('path-dirname');
pathDirname('/home/foo');
//=> '/home'
pathDirname('C:\\Users\\foo');
//=> 'C:\\Users'
pathDirname('foo');
//=> '.'
pathDirname('foo/bar');
//=> 'foo'
//Using posix version for consistent output when dealing with glob escape chars
pathDirname.win32('C:\\Users\\foo/\\*bar');
//=> 'C:\\Users\\foo/'
pathDirname.posix('C:\\Users\\foo/\\*bar');
//=> 'C:\\Users\\foo'
See the path.dirname() docs.
POSIX specific version.
Windows specific version.
MIT
The 'path' module is a core Node.js module that provides utilities for working with file and directory paths. It includes the path.dirname function, which offers similar functionality to path-dirname. The main difference is that 'path' is built into Node.js and provides a broader range of path-related utilities, whereas path-dirname is a lightweight alternative focused solely on extracting directory names.
The 'upath' package is a utility for working with file paths across different operating systems. It provides a consistent API for handling paths, including a dirname function similar to path-dirname. Unlike path-dirname, upath is designed to handle cross-platform path issues, making it more versatile for projects that need to run on multiple operating systems.
FAQs
Node.js path.dirname() ponyfill
The npm package path-dirname receives a total of 7,318,603 weekly downloads. As such, path-dirname popularity was classified as popular.
We found that path-dirname demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.