source: trip-planner-front/node_modules/resolve-from/readme.md@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1# resolve-from [![Build Status](https://travis-ci.org/sindresorhus/resolve-from.svg?branch=master)](https://travis-ci.org/sindresorhus/resolve-from)
2
3> Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from a given path
4
5
6## Install
7
8```
9$ npm install resolve-from
10```
11
12
13## Usage
14
15```js
16const resolveFrom = require('resolve-from');
17
18// There is a file at `./foo/bar.js`
19
20resolveFrom('foo', './bar');
21//=> '/Users/sindresorhus/dev/test/foo/bar.js'
22```
23
24
25## API
26
27### resolveFrom(fromDir, moduleId)
28
29Like `require()`, throws when the module can't be found.
30
31### resolveFrom.silent(fromDir, moduleId)
32
33Returns `null` instead of throwing when the module can't be found.
34
35#### fromDir
36
37Type: `string`
38
39Directory to resolve from.
40
41#### moduleId
42
43Type: `string`
44
45What you would use in `require()`.
46
47
48## Tip
49
50Create a partial using a bound function if you want to resolve from the same `fromDir` multiple times:
51
52```js
53const resolveFromFoo = resolveFrom.bind(null, 'foo');
54
55resolveFromFoo('./bar');
56resolveFromFoo('./baz');
57```
58
59
60## Related
61
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
68
69
70## License
71
72MIT © [Sindre Sorhus](https://sindresorhus.com)
Note: See TracBrowser for help on using the repository browser.