![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
path-exists
Advanced tools
The path-exists npm package is used to check if a file or directory exists on the file system without using fs.existsSync. It is built on top of Node.js's fs.promises API and provides a simple promise-based interface.
Check if a path exists
This feature allows you to check if a file or directory exists asynchronously by returning a promise that resolves to either true or false.
const pathExists = require('path-exists');
(async () => {
const exists = await pathExists('/path/to/file');
console.log(exists);
//=> true or false
})();
Check if a path exists synchronously
This feature provides a synchronous way to check if a file or directory exists, returning a boolean value immediately.
const pathExists = require('path-exists');
const exists = pathExists.sync('/path/to/file');
console.log(exists);
//=> true or false
fs-extra is a package that extends the built-in fs module, providing additional methods and ensuring consistency across platforms. It includes the 'pathExists' and 'pathExistsSync' methods, which are similar to the functionality provided by path-exists. fs-extra offers a broader set of file system operations, making it a more comprehensive choice for file system interactions.
make-dir is a package that focuses on creating directories and their parent directories if they don't exist. While it doesn't provide a direct method to check for the existence of a path, it is related in the sense that it handles the existence of directories as part of its operation. It differs from path-exists as it is more about directory creation than existence checking.
Check if a path exists
NOTE: fs.existsSync
has been un-deprecated in Node.js since 6.8.0. If you only need to check synchronously, this module is not needed.
Never use this before handling a file though:
In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to
fs.exists()
andfs.open()
. Just open the file and handle the error when it's not there.
$ npm install path-exists
// foo.js
import {pathExists} from 'path-exists';
console.log(await pathExists('foo.js'));
//=> true
Returns a Promise<boolean>
of whether the path exists.
Returns a boolean
of whether the path exists.
FAQs
Check if a path exists
The npm package path-exists receives a total of 62,963,965 weekly downloads. As such, path-exists popularity was classified as popular.
We found that path-exists 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.