Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
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,997,737 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.