package
Resolve a dependency of another package.
npm install pkgresolveGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
53.2 kB
Includes dependencies.
Useful for hacks, monkeypatching or wrappers that require manipulation of the exact dependency that would be loaded by a package.
npm install --save pkgresolvevar 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
})# Resolve 'through' from locally installed 'tape'
pkgresolve tape through
# Resolve 'npmconf' from globally installed 'npm'
pkgresolve --global npm npmconfrequire('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.
This intentially breaks the encapsulation provided by node/npm's module system. Don't use this unless you have to.
MIT