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

pkgresolve

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pkgresolve

Resolve a dependency of another package.

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4K
increased by70.93%
Maintainers
1
Weekly downloads
 
Created
Source

pkgresolve

Resolve a dependency from within the context of another package.

Build Status

Useful for hacks, monkeypatching or wrappers that require manipulation of the exact dependency that would be loaded by a package.

Installation

npm install --save pkgresolve

Example

var resolve = require('pkgresolve')

// Resolve 'through' from locally installed 'tape'
resolve('through').from('tape', function(err, pkgPath) {
  // pkgPath - path to through or null
})

// Resolve 'npmconf' from globally installed 'npm'
resolve('npmconf').fromGlobal('npm', function(err, pkgPath) {
  // pkgPath - path to npmconf or null
})

CLI

# Resolve 'through' from locally installed 'tape'
pkgresolve tape through

# Resolve 'npmconf' from globally installed 'npm'
pkgresolve --global npm npmconf

Why not require('parent/node_modules/child')?

Due to deduplication, child is not guaranteed to exist at that location. You don't even need to call npm dedupe for this to happen – npm will not install something that is already installed in the hierarchy. pkgresolve is a more robust method.

Use Responsibly.

This intentially breaks the encapsulation provided by node/npm's module system. Don't use this unless you have to.

See Also

License

MIT

Keywords

FAQs

Package last updated on 09 Dec 2016

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