pkg-up

Find the closest package.json file

Renamed to package-up
Last updated a year ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install pkg-up 
SYNC missed versions from official npm registry.

pkg-up

Find the closest package.json file

Install

npm install pkg-up

Usage

/
└── Users
    └── sindresorhus
        └── foo
            ├── package.json
            └── bar
                ├── baz
                └── example.js
// example.js
import {pkgUp} from 'pkg-up';

console.log(await pkgUp());
//=> '/Users/sindresorhus/foo/package.json'

API

pkgUp(options?)

Returns a Promise<string> for the file path, or Promise<undefined> if it could not be found.

pkgUpSync(options?)

Returns the file path, or undefined if it could not be found.

options

Type: object

cwd

Type: string
Default: process.cwd()

The directory to start from.

Related

  • read-pkg-up - Read the closest package.json file
  • pkg-dir - Find the root directory of an npm package
  • find-up - Find a file by walking up parent directories

Current Tags

  • 5.0.0                                ...           latest (a year ago)

7 Versions

  • 5.0.0 [deprecated]           ...           a year ago
  • 4.0.0                                ...           3 years ago
  • 3.1.0                                ...           6 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.0                                ...           8 years ago
  • 1.0.0                                ...           9 years ago

© 2010 - cnpmjs.org x YWFE | Home | YWFE