Registry / http-networking / x-path

x-path

JSON →
library0.0.2jsnpmunverified

The `x-path` package extends Node.js's native `path` module, providing additional utilities for path manipulation and basic file system checks. It offers methods such as `isAbsolutePath`, `isRelativePath`, `isRootDirectory`, `unifyPathSeparate`, `normalizePathSeparate`, and functions to check if a path refers to a directory or file (`isDirectory`, `isFile`, `isDirectorySync`, `isFileSync`). It also includes functions for retrieving common system directories like `tempdir`, `homedir`, and `datadir`, which are sourced from the `path-extra` package. The current and only release is version 0.0.2, published in 2015. Given its age and complete lack of updates, the package is considered abandoned, with no active development or release cadence. Its initial purpose was to fill gaps in Node.js's built-in `path` module, many of which have since been addressed by the core Node.js `path`, `os`, and `fs` modules, or by widely adopted and maintained third-party alternatives.

npm install x-path
INSTALL
IMPORT
SIG · X-PATH
X
x-path
http-networkingjavascriptv0.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

path
const path = require('x-path');
import path from 'x-path';
This package is CommonJS-only. Direct ESM 'import' statements will not work without a CommonJS wrapper or bundler configuration.
isAbsolutePath
const path = require('x-path'); path.isAbsolutePath('/foo/bar');
import { isAbsolutePath } from 'x-path';
Individual functions are exported as properties of the main `path` object, not as named exports. Modern Node.js provides `path.isAbsolute` natively.
isDirectorySync
const path = require('x-path'); path.isDirectorySync('./my-dir');
const { isDirectorySync } = require('x-path');
Functions are properties of the main exported object. Synchronous file system operations are generally discouraged in Node.js for blocking the event loop; prefer `fs.stat` with promises or callbacks for async checks.

Demonstrates basic path checks (`isAbsolutePath`, `isRelativePath`), synchronous file system queries (`isDirectorySync`, `isFileSync`), and retrieval of system directories (`tempdir`, `homedir`).

const path = require('x-path'); const fs = require('fs'); const os = require('os'); // Create a dummy file and directory for testing file system checks const testDirPath = './temp-test-dir'; const testFilePath = './temp-test-dir/test-file.txt'; if (!fs.existsSync(testDirPath)) { fs.mkdirSync(testDirPath); } fs.writeFileSync(testFilePath, 'Hello, x-path!'); console.log('--- x-path Usage Examples ---'); // Path checks console.log(`Is '/usr/local/bin' an absolute path? ${path.isAbsolutePath('/usr/local/bin')}`); console.log(`Is 'relative/path' a relative path? ${path.isRelativePath('relative/path')}`); // File system checks (synchronous, generally discouraged) console.log(`Is '${testDirPath}' a directory? ${path.isDirectorySync(testDirPath)}`); console.log(`Is '${testFilePath}' a file? ${path.isFileSync(testFilePath)}`); console.log(`Is './nonexistent' a directory? ${path.isDirectorySync('./nonexistent')}`); // System directories console.log(`Temporary directory: ${path.tempdir()}`); console.log(`Home directory: ${path.homedir()}`); // Clean up dummy files/directories fs.unlinkSync(testFilePath); fs.rmdirSync(testDirPath); console.log('\nCleaned up temporary test files.');
Debug
Known issues
breakingThe package is effectively abandoned, with its last update in 2015 (version 0.0.2). It is not compatible with modern Node.js module systems (ESM) and its internal dependencies may contain unpatched vulnerabilities or rely on outdated APIs.
fix
Migrate to native Node.js `path`, `os`, and `fs` modules (e.g., `path.isAbsolute`, `os.homedir`, `os.tmpdir`, `fs.stat`) or use actively maintained alternatives like `fs-extra` for extended file system operations.
affects: >=0.0.2
gotchaThis package is CommonJS-only. Attempting to use `import` statements directly in an ESM project will result in module resolution errors. It was published long before widespread ESM adoption in Node.js.
fix
For CommonJS, use `const path = require('x-path');`. For ESM projects, rewrite functionality using native Node.js modules or modern, ESM-compatible libraries. If absolutely necessary, you might configure a bundler to transpile or wrap CommonJS modules.
affects: >=0.0.1
deprecatedMany of the utilities provided by `x-path`, such as `isAbsolutePath`, `homedir`, and `tempdir`, now have direct equivalents in Node.js's built-in `path` and `os` modules. The `fs.stat` methods provide robust, asynchronous file system checks.
fix
Replace `path.isAbsolutePath` with `path.isAbsolute` (from `node:path`), `path.homedir` with `os.homedir()` (from `node:os`), `path.tempdir` with `os.tmpdir()` (from `node:os`). For file/directory checks, use `fs.stat` or `fs.promises.stat` for asynchronous, non-blocking operations.
affects: >=0.0.1
gotchaThe `isDirectorySync` and `isFileSync` methods perform synchronous file system operations. These block the Node.js event loop, leading to performance issues and unresponsiveness, especially in server applications or for large file operations.
fix
Always prefer asynchronous file system methods. Use `fs.promises.stat(path)` or `fs.stat(path, callback)` and check the `stats` object (`stats.isDirectory()`, `stats.isFile()`) to determine file or directory type without blocking.
affects: >=0.0.1
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` in an ES module context or a browser environment where CommonJS is not supported.
fix
This package is CommonJS-only. If in an ESM project, rewrite the functionality using native Node.js modules (`import { isAbsolute } from 'node:path';`) or modern alternatives. If in a browser, use client-side path utilities or a bundler to transpile.
TypeError: path.isAbsolutePath is not a function
Trying to destructure `isAbsolutePath` (e.g., `const { isAbsolutePath } = require('x-path');`) or calling it on an undefined `path` object.
fix
The package exports a single object containing all functions. Use `const path = require('x-path');` and then access methods as `path.isAbsolutePath(somePath);`. Ensure `require('x-path')` successfully returns the module object.
MODULE_NOT_FOUND: Cannot find package 'x-path' imported from ...
Using `import path from 'x-path';` in an ES module environment without proper CommonJS interoperability configuration, or the package is simply not installed.
fix
Ensure `npm install x-path` has been run. If in an ESM project, this package is not designed for direct `import`. Consider migrating to native Node.js `path`, `os`, and `fs` modules, which are ESM-compatible. Otherwise, if interoperability is configured, ensure correct path resolution.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
path-extrarequiredProvides additional system directory functions like tempdir, homedir, and datadir.
Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
x-path — npm install x-path · libregistry