1 # resolve-from [![Build Status](https://travis-ci.org/sindresorhus/resolve-from.svg?branch=master)](https://travis-ci.org/sindresorhus/resolve-from)
3 > Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from a given path
9 $ npm install resolve-from
16 const resolveFrom = require('resolve-from');
18 // There is a file at `./foo/bar.js`
20 resolveFrom('foo', './bar');
21 //=> '/Users/sindresorhus/dev/test/foo/bar.js'
27 ### resolveFrom(fromDir, moduleId)
29 Like `require()`, throws when the module can't be found.
31 ### resolveFrom.silent(fromDir, moduleId)
33 Returns `null` instead of throwing when the module can't be found.
39 Directory to resolve from.
45 What you would use in `require()`.
50 Create a partial using a bound function if you want to resolve from the same `fromDir` multiple times:
53 const resolveFromFoo = resolveFrom.bind(null, 'foo');
55 resolveFromFoo('./bar');
56 resolveFromFoo('./baz');
62 - [resolve-cwd](https://github.com/sindresorhus/resolve-cwd) - Resolve the path of a module from the current working directory
63 - [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path
64 - [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory
65 - [resolve-pkg](https://github.com/sindresorhus/resolve-pkg) - Resolve the path of a package regardless of it having an entry point
66 - [import-lazy](https://github.com/sindresorhus/import-lazy) - Import a module lazily
67 - [resolve-global](https://github.com/sindresorhus/resolve-global) - Resolve the path of a globally installed module
72 MIT © [Sindre Sorhus](https://sindresorhus.com)