# resolve-pkg

> Resolve the path of a package regardless of it having an entry point

Latest version **3.0.1** (published 2026-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install resolve-pkg
pnpm add resolve-pkg
yarn add resolve-pkg
bun add resolve-pkg
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2026-02-12 |
| First published | 2015-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 54 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | require, resolve, path, module, from, like, path, cwd, current, working, directory, grunt, main, entry, point |

## Links

- npm: https://www.npmjs.com/package/resolve-pkg
- Repository: https://github.com/sindresorhus/resolve-pkg
- Homepage: https://github.com/sindresorhus/resolve-pkg#readme
- Issues: https://github.com/sindresorhus/resolve-pkg/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/resolve-pkg

## Dependencies (1)

- [find-up-simple](https://npm.io/package/find-up-simple.md) ^1.0.1

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 3.0.1 (latest) — 2026-02-12
- 3.0.0 — 2026-02-02
- 2.0.0 — 2019-04-16
- 1.0.0 — 2017-01-13
- 0.2.0 — 2016-08-05
- 0.1.0 — 2015-12-19

## README

# resolve-pkg

> Resolve the path of a package regardless of it having an entry point

Some packages like CLI tools and Grunt tasks don't have an entry point defined in package.json, resulting in them not being resolvable by `import.meta.resolve()`. Unlike `import.meta.resolve()`, this package also resolves packages without an entry point and returns `undefined` instead of throwing when the package can't be found.

## Install

```sh
npm install resolve-pkg
```

## Usage

```js
import resolvePackage from 'resolve-pkg';

// $ npm install --save-dev grunt-svgmin

resolvePackage('grunt-svgmin/tasks', {cwd: import.meta.dirname});
//=> '/Users/sindresorhus/unicorn/node_modules/grunt-svgmin/tasks'

// Fails here as Grunt tasks usually don't have a defined entry point
import.meta.resolve('grunt-svgmin/tasks');
//=> Error
```

## API

### resolvePackage(moduleId, options?)

#### moduleId

Type: `string`

What you would use in `import`.

#### options

##### cwd

Type: `string`<br>
Default: `process.cwd()`

Directory to resolve from.

## Related

- [resolve-cwd](https://github.com/sindresorhus/resolve-cwd) - Resolve the path of a module from the current working directory
- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module from a given path
- [resolve-global](https://github.com/sindresorhus/resolve-global) - Resolve the path of a globally installed module
- [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path
- [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory
- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import a module lazily

---
_Source: https://npm.io/package/resolve-pkg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
