Socket
Book a DemoInstallSign in
Socket

@cjkihl/find-root

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cjkihl/find-root

Find monorepo root directory by detecting lockfiles

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
71
787.5%
Maintainers
1
Weekly downloads
 
Created
Source

@cjkihl/find-root

A utility to find the root directory of a monorepo by detecting lockfiles. Supports multiple package managers including npm, yarn, pnpm, and Bun.

Installation

bun add @cjkihl/find-root

Usage

import { findRoot } from '@cjkihl/find-root';

// Find the root directory of your monorepo
const { root, lockfile, packageManager } = await findRoot();
console.log(`Root directory: ${root}`);
console.log(`Lockfile: ${lockfile}`);
console.log(`Package manager: ${packageManager}`);

API

findRoot()

Returns a Promise that resolves to an object containing:

  • root: The absolute path to the monorepo root directory
  • lockfile: The absolute path to the detected lockfile
  • packageManager: The detected package manager ('npm', 'yarn', 'pnpm', or 'bun')

Supported Lockfiles

  • package-lock.json (npm)
  • yarn.lock (yarn)
  • pnpm-lock.yaml (pnpm)
  • bun.lock (Bun)
  • bun.lockb (Bun)

Error Handling

The function will throw an error if:

  • No lockfile is found in the current directory or any parent directory
  • The detected lockfile is not recognized

License

MIT

Keywords

monorepo

FAQs

Package last updated on 26 Jun 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.