root / HServer / 00.Server / 00.Program / node_modules / resolve-from / readme.md
이력 | 보기 | 이력해설 | 다운로드 (1.06 KB)
1 |
# resolve-from [](https://travis-ci.org/sindresorhus/resolve-from) |
---|---|
2 |
|
3 |
> Resolve the path of a module like [`require.resolve()`](http://nodejs.org/api/globals.html#globals_require_resolve) but from a given path |
4 |
|
5 |
Unlike `require.resolve()` it returns `null` instead of throwing when the module can't be found. |
6 |
|
7 |
|
8 |
## Install |
9 |
|
10 |
``` |
11 |
$ npm install --save resolve-from |
12 |
``` |
13 |
|
14 |
|
15 |
## Usage |
16 |
|
17 |
```js |
18 |
const resolveFrom = require('resolve-from'); |
19 |
|
20 |
// there's a file at `./foo/bar.js` |
21 |
|
22 |
resolveFrom('foo', './bar'); |
23 |
//=> '/Users/sindresorhus/dev/test/foo/bar.js' |
24 |
``` |
25 |
|
26 |
|
27 |
## API |
28 |
|
29 |
### resolveFrom(fromDir, moduleId) |
30 |
|
31 |
#### fromDir |
32 |
|
33 |
Type: `string` |
34 |
|
35 |
Directory to resolve from. |
36 |
|
37 |
#### moduleId |
38 |
|
39 |
Type: `string` |
40 |
|
41 |
What you would use in `require()`. |
42 |
|
43 |
|
44 |
## Tip |
45 |
|
46 |
Create a partial using a bound function if you want to require from the same `fromDir` multiple times: |
47 |
|
48 |
```js |
49 |
const resolveFromFoo = resolveFrom.bind(null, 'foo'); |
50 |
|
51 |
resolveFromFoo('./bar'); |
52 |
resolveFromFoo('./baz'); |
53 |
``` |
54 |
|
55 |
|
56 |
## License |
57 |
|
58 |
MIT © [Sindre Sorhus](http://sindresorhus.com) |