bare-path is a JavaScript library designed for cross-platform path manipulation, focusing on string-based operations rather than interacting with the underlying file system. It provides utilities for joining, normalizing, resolving, and dissecting file paths, similar to Node.js's built-in `path` module. The current stable version is 3.0.0. Its primary differentiator is its minimalist approach and explicit separation of POSIX and Windows path logic via subpath exports, making it highly portable and suitable for environments where `node:path` might not be available or desired due to its implicit OS-specific behavior. It maintains a steady release cadence for core utility packages, prioritizing stability and broad compatibility.
npm install bare-pathVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic path manipulation functions like joining, normalizing, and extracting parts of a path using `bare-path`.
Migrate to standard ES module imports (e.g., `import path from 'bare-path'`) and use the official subpath exports (`bare-path/win32`, `bare-path/posix`) for platform-specific utilities. Ensure your `package.json` specifies `"type": "module"` for ESM usage or correctly configures a CJS environment.
Understand that `bare-path` operates solely on the provided string inputs. For file system interactions (e.g., `fs.readFile`), use `node:path` methods if you need guarantees about actual file system paths, or manually combine `bare-path` outputs with `process.cwd()` for root-relative paths.
Prefer `path.join()`, `path.resolve()`, and `path.normalize()` methods for cross-platform compatibility. If you need strict platform behavior, explicitly import and use `bare-path/posix` or `bare-path/win32`.
If using ES modules, ensure you are using `import path from 'bare-path';`. If in a CommonJS context, use `const path = require('bare-path');`. Verify that your `package.json` has `"type": "module"` if you intend to use ESM globally, or manage file extensions (`.mjs`/`.cjs`).Before dynamically importing a local absolute path on Windows, convert it to a `file://` URL: `import { pathToFileURL } from 'node:url'; const modulePath = pathToFileURL(absolutePath).href; await import(modulePath);`