
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
exists-file
Advanced tools
Check if a file exists. A fs.exists implementation that is not deprecated.
Check if a file exists. A fs.exists implementation that is not deprecated.
Because fs.exist and fs.existsSync are deprecated this an implementation using fs.stats and fs.statsSync for get the same result.
Also always keep in mind:
fs.exists() should not be used to check if a file exists before calling fs.open(). Doing so introduces a race condition since other processes may change the file's state between the two calls. Instead, user code should call fs.open() directly and handle the error raised if the file is non-existent.
npm install exists-file --save
var existsFile = require('exists-file')
// async with a callback
existsFile('./README.md', console.log) // => null, true
// async with a promise
existsFile('./README.md').then(console.log).catch(console.error) // => true
// sync
var exists = existsFile.sync('./README.md')
console.log(exists) // => true
Required
Type: string
The relative or absolute file path.
Type: function
If cb
is not provided then it returns a promise
.
Required
Type: string
The relative or absolute file path.
MIT © Kiko Beats
FAQs
Check if a file exists. A fs.exists implementation that is not deprecated.
The npm package exists-file receives a total of 3,999 weekly downloads. As such, exists-file popularity was classified as popular.
We found that exists-file 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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.