Giter VIP home page Giter VIP logo

use-root-path's Introduction

use-root-path

Enables root-based require statements in node.js.

This module is based on fabmos' wonderful node.js helper named rootpath. This version is just a tiny bit cleaner to use, slightly more descriptive, and involves less code behind the scenes. Like the original, this version works with your existing local and global modules. All props to fabmos!

Install

npm install use-root-path

Usage

require( 'use-root-path' );

Examples

Before (the usual relative local paths in node.js)

var lib     = require( './app/lib/library' );
var util    = require( '../../app/utilities/util'  );
var test    = require( '../../app/unit-tests/test' );
var morgan  = require( 'morgan'  );
var express = require( 'express' );

After (root-based local paths in node.js)

require( 'use-root-path' );

var lib     = require( 'app/lib/library' );
var util    = require( 'app/utilities/util'  );
var test    = require( 'app/unit-tests/test' );
var morgan  = require( 'morgan'  );
var express = require( 'express' );

Notes

Place require( 'use-root-path' ); at the top of any module that you want to use root-based require statements. This is completely friendly with global modules too, as shown in the examples above.

Version

0.1.0 Initial Release

License

MIT

use-root-path's People

Contributors

wdrol avatar

Stargazers

Davorin Šego avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.