package-resolver

1.1.0 • Public • Published

package-resolver

Resolve the location of a package installed on disk.

Why not use require.resolve()?

  • package-resolver is more specialized than require.resolve and this allows for optimizations which lead to less file-system operations.
  • using require.resolve() to find the location of a package is broken when this package uses the exports feature More here

Usage

const { resolvePackage } = require("package-resolver");

(async function() {
  try {
    const result = await resolvePackage("react", process.cwd());
    console.log("react is installed here:", result);
  } catch {
    console.log("Cannot resolve react");
  }
})()


Readme

Keywords

none

Package Sidebar

Install

npm i package-resolver

Weekly Downloads

385

Version

1.1.0

License

MIT

Unpacked Size

4.42 kB

Total Files

5

Last publish

Collaborators

  • vincentbailly