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

local-pkg

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

local-pkg

Get information on local packages.

  • 0.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.4M
increased by4.97%
Maintainers
1
Weekly downloads
 
Created

What is local-pkg?

The 'local-pkg' npm package is designed to help developers manage and interact with local packages in a Node.js environment. It provides utilities to check for the existence of local packages, resolve their paths, and require them conditionally.

What are local-pkg's main functionalities?

Check if a local package exists

This feature allows you to check if a specific local package is installed. The function `isPackageExists` returns a boolean indicating the presence of the package.

const { isPackageExists } = require('local-pkg');

if (isPackageExists('some-local-package')) {
  console.log('Package exists');
} else {
  console.log('Package does not exist');
}

Resolve the path of a local package

This feature helps you resolve the absolute path of a local package. The function `resolvePackagePath` returns the path as a string.

const { resolvePackagePath } = require('local-pkg');

const packagePath = resolvePackagePath('some-local-package');
console.log(`Package path: ${packagePath}`);

Require a local package conditionally

This feature allows you to require a local package conditionally. The function `requireModule` attempts to require the package and returns it if successful, otherwise it returns `null`.

const { requireModule } = require('local-pkg');

const someLocalPackage = requireModule('some-local-package');
if (someLocalPackage) {
  console.log('Package loaded successfully');
} else {
  console.log('Failed to load package');
}

Other packages similar to local-pkg

Keywords

FAQs

Package last updated on 12 Jul 2022

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