JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5321
  • Score
    100M100P100Q121802F
  • License MIT

Resolve a dependency of another package.

Package Exports

  • pkgresolve

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pkgresolve) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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