Registry / devops / glob2base

glob2base

JSON →
library0.0.12jsnpmunverified

glob2base is a small, focused utility library for Node.js that extracts the static base path portion from a `node-glob` instance. It identifies the non-globbing part of a pattern (e.g., `js/` from `js/**/*.js`), allowing for operations on the fixed directory structure before any file matching occurs. The current stable version is 0.0.12, which was last updated in 2015. The project appears to be unmaintained, with no significant updates in a long time, indicating an abandoned release cadence. Its primary differentiator is its direct integration with `node-glob`'s internal structure to derive the base path, rather than attempting to parse glob strings independently, though this tight coupling might also limit its flexibility with other glob implementations or newer `node-glob` versions.

npm install glob2base
INSTALL
IMPORT
SIG · GLOB2BASE
G
glob2base
devopsjavascriptv0.0.12
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.

(Default Export)
const glob2base = require('glob2base');
import glob2base from 'glob2base';
This package is a CommonJS module and exports a single function as its default. Direct `import` statements will fail in pure ESM environments or without transpilation due to its CJS nature.
Glob (from 'glob')
const glob = require('glob'); const globInstance = new glob.Glob('pattern');
import { Glob } from 'glob'; const globInstance = new Glob('pattern');
glob2base expects an instance of `glob.Glob`. Ensure the `glob` package is imported correctly, typically using CommonJS `require()` as well, especially if using an older version of `glob`.

This quickstart demonstrates how to import `glob2base` and `glob`, then use `glob2base` to extract the common base path from various `node-glob` patterns, printing the result to the console.

const glob2base = require('glob2base'); const glob = require('glob'); // Make sure 'glob' is installed (npm install glob) // Create a new Glob instance for 'js/**/*.js' const globInstance1 = new glob.Glob('js/**/*.js'); const base1 = glob2base(globInstance1); console.log(`Base path for 'js/**/*.js': ${base1}`); // Expected output: js/ // Create a new Glob instance for 'css/test/{a,b}/*.css' const globInstance2 = new glob.Glob('css/test/{a,b}/*.css'); const base2 = glob2base(globInstance2); console.log(`Base path for 'css/test/{a,b}/*.css': ${base2}`); // Expected output: css/test/ // Create a new Glob instance for a specific file 'pages/whatever/index.html' const globInstance3 = new glob.Glob('pages/whatever/index.html'); const base3 = glob2base(globInstance3); console.log(`Base path for 'pages/whatever/index.html': ${base3}`); // Expected output: pages/whatever/
Debug
Known issues
breakingThe package has not been updated since 2015 and is considered abandoned. It may contain unpatched security vulnerabilities or have compatibility issues with modern Node.js environments and newer versions of its `glob` dependency.
fix
Consider migrating to a maintained alternative or thoroughly auditing the package for security and compatibility if continued use is necessary.
affects: 0.0.12
gotcha`glob2base` is a CommonJS module. Attempting to use `import` statements directly in a pure ESM project will lead to errors.
fix
Use `const glob2base = require('glob2base');` for CJS environments or configure your ESM project to correctly interoperate with CommonJS modules (e.g., using `createRequire` in Node.js ESM).
affects: 0.0.12
gotchaThere are no official TypeScript declaration files (`.d.ts`) provided for `glob2base`. Users integrating this package into TypeScript projects will need to create their own ambient module declarations.
fix
Create a `glob2base.d.ts` file with `declare module 'glob2base' { function glob2base(globInstance: any): string; export = glob2base; }` or a more specific type if desired.
affects: 0.0.12
gotcha`glob2base` relies on the internal structure of `node-glob` instances. Future major versions of the `glob` package could introduce breaking changes to its internal `Glob` class, potentially causing `glob2base` to malfunction.
fix
Test `glob2base` thoroughly if updating the `glob` dependency to a new major version. If issues arise, consider pinning an older, compatible `glob` version or seeking an alternative base path extractor.
affects: 0.0.12
gotchaThe package's `engines` field specifies Node.js `>= 0.10`, which is extremely outdated. While simple CJS modules often function on newer Node.js versions, there's no guarantee of full compatibility or optimal performance.
fix
Proceed with caution on modern Node.js versions. If encountering unexpected behavior, investigate potential incompatibilities or use an alternative.
affects: 0.0.12
Errors
Common errors & fixes
TypeError: glob2base is not a function
This error typically occurs when `glob2base` is not correctly imported as a default (function) export, often by attempting `import { glob2base } from 'glob2base';`.
fix
Ensure you are using the CommonJS default import: `const glob2base = require('glob2base');`.
ERR_REQUIRE_ESM or SyntaxError: Cannot use import statement outside a module
Attempting to `import glob2base from 'glob2base';` in a CommonJS module context or an unconfigured pure ESM environment without proper interop setup.
fix
Change the import statement to a CommonJS `require`: `const glob2base = require('glob2base');`.
TypeError: Cannot read properties of undefined (reading 'minimatch') or similar errors related to `glob` internals.
This issue arises when `glob2base` attempts to access internal properties of the `glob` instance that have either changed or been removed in a newer major version of the `glob` package, leading to incompatibility.
fix
Try installing an older, compatible version of the `glob` package (e.g., `npm install glob@^7.0.0` or `glob@^6.0.0`) or consider using a more recently maintained alternative for extracting base paths from glob patterns.
Upgrade
Version history
0.0.12latest on npm
Audit
Dependencies
globrequiredglob2base takes an instance of `node-glob` as its input, making `glob` a core runtime dependency for any practical use.
Agent activity
2 hits · last 30 days
node
2
Resources
glob2base — npm install glob2base · libregistry