
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
realpath-native
Advanced tools
The realpath-native npm package provides a way to resolve the real path of a file or directory, similar to the native `fs.realpath` method but with better performance and additional features.
Resolve Real Path
This feature allows you to resolve the real path of a given file or directory. It works asynchronously and provides a callback with the resolved path.
const realpathNative = require('realpath-native');
realpathNative('/some/path', (err, resolvedPath) => {
if (err) throw err;
console.log(resolvedPath);
});
Synchronous Real Path Resolution
This feature allows you to resolve the real path of a given file or directory synchronously. It throws an error if the path cannot be resolved.
const realpathNative = require('realpath-native');
try {
const resolvedPath = realpathNative.sync('/some/path');
console.log(resolvedPath);
} catch (err) {
console.error(err);
}
Promise-based Real Path Resolution
This feature allows you to resolve the real path of a given file or directory using Promises, making it easier to work with async/await syntax.
const realpathNative = require('realpath-native');
realpathNative.promise('/some/path')
.then(resolvedPath => console.log(resolvedPath))
.catch(err => console.error(err));
fs-extra is a package that extends the native `fs` module with additional methods and features, including methods for resolving real paths. It provides both callback and promise-based APIs, similar to realpath-native.
graceful-fs is a drop-in replacement for the native `fs` module that improves handling of file system operations, including real path resolution. It aims to handle errors more gracefully and provide better performance.
path-exists is a simple package that checks if a given path exists. While it does not directly resolve real paths, it can be used in conjunction with other packages to ensure a path exists before resolving it.
Use the system's native
realpath
Node 9.3 added fs.realpath(Sync).native
. On older Nodes you have to use
process.binding
to access the same function. This module does that check for
you.
The advantage of the native realpath
over fs.realpath
is that the native one
better supports paths on Windows.
On node 4 the function uses the old fs.realpath
function.
Install the module with npm
:
$ npm install realpath-native
const realpath = require('realpath-native');
realpath('some-path'); // returns a promise
realpath.sync('some-path');
Returns a promise for the resolved path of the input.
Type: string
Returns the resolved path of the input synchronously.
Type: string
FAQs
Use the system's native `realpath`
The npm package realpath-native receives a total of 1,090,076 weekly downloads. As such, realpath-native popularity was classified as popular.
We found that realpath-native 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
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.