File: README.md

package info (click to toggle)
node-require-relative 0.8.7-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 72 kB
  • sloc: javascript: 25; sh: 2; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# require-relative

require-relative is a node.js program to require and resolve modules relative to a path of your choice.
It exploits node.js's own `module` module, and has no additional dependencies.

## Example

requiring modules relatively

```js
var relative = require('require-relative');

var someModule = relative('./some-module', '/home/kamicane');
var somePackage = relative('some-package', '/home/kamicane');
var isTrue = relative('./some-module.js', process.cwd()) === relative('./some-module.js');
```

resolving filenames relatively

```js
var relative = require('require-relative');

relative.resolve('./some-module', '/home/kamicane'); // /home/kamicane/some-module.js
relative.resolve('some-package', '/home/kamicane'); // /home/kamicane/node_modules/some-package/index.js
var isTrue = relative.resolve('./some-module.js', process.cwd()) === relative.resolve('./some-module.js');
```