require-relative
require and resolve modules relative to a path of your choice
Last updated 7 years ago by kamicane .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install require-relative 
SYNC missed versions from official npm registry.

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

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

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');

Current Tags

  • 0.8.7                                ...           latest (7 years ago)

1 Versions

  • 0.8.7                                ...           7 years ago
Maintainers (1)
Downloads
Today 16
This Week 16
This Month 1,761
Last Day 134
Last Week 2,743
Last Month 10,790
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (151)

Copyright 2014 - 2016 © taobao.org |