Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rfr

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rfr

Require From project Root tool for Node.js.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
decreased by-15.7%
Maintainers
1
Weekly downloads
 
Created
Source

node-rfr

node-rfr is a Require From project Root tool for Node.js.

node-rfr allows you to require modules in your project with rfr('/lib/module1.js') instead of something like require('../../lib/module1.js').

Install

npm install rfr

Usage

Suppose we have a project structed as the following:

project
|--package.json
|--run.js
|--lib
   |--module1.js
   |--module2.js

If we run run.js in the project folder, we can require modules relatively like this:

var rfr = require('rfr');
var module1 = rfr('/lib/module1');
var module2 = rfr('/lib/module2');

Customize the Root

By default, the root path is the current working path where you run the program. If you want to use another path as the root, set it to the environment variable named RFR_ROOT before you require node-rfr. For example, run the program like this:

RFR_ROOT=<some_path> node run.js

Or set it with the following code:

rfr.setRoot('some_path');

The root should be an absolute path. Maybe you want to use __dirname.

Keywords

FAQs

Package last updated on 16 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc