Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pkg-up

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pkg-up

Find the closest package.json file

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.3M
decreased by-5.88%
Maintainers
1
Weekly downloads
 
Created

What is pkg-up?

The pkg-up npm package is used to find the closest package.json file in the directory tree, starting from a given directory. It is useful for Node.js projects where you need to locate the package.json file of the current project or a related package.

What are pkg-up's main functionalities?

Find the closest package.json

This feature allows you to asynchronously find the nearest package.json file from the current directory.

const pkgUp = require('pkg-up');

(async () => {
  const filePath = await pkgUp();
  console.log(filePath);
  //=> '/Users/sindresorhus/foo/package.json'
})();

Find the closest package.json synchronously

This feature provides a synchronous method to find the nearest package.json file.

const pkgUp = require('pkg-up');

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

Find package.json from a specific directory

This feature allows you to find the nearest package.json file starting from a specific directory.

const pkgUp = require('pkg-up');

(async () => {
  const filePath = await pkgUp({cwd: 'some/subdirectory'});
  console.log(filePath);
  //=> '/Users/sindresorhus/foo/package.json'
})();

Other packages similar to pkg-up

Keywords

FAQs

Package last updated on 04 Nov 2023

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc