https://github.com/7elven/abrequire
Better local require
https://github.com/7elven/abrequire
absolute nodejs path require
Last synced: about 2 months ago
JSON representation
Better local require
- Host: GitHub
- URL: https://github.com/7elven/abrequire
- Owner: 7elven
- Created: 2018-06-20T08:01:04.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-03T06:14:08.000Z (about 7 years ago)
- Last Synced: 2025-12-31T21:13:18.867Z (6 months ago)
- Topics: absolute, nodejs, path, require
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/abrequire
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# abrequire
A-B-Require is pretty require with absolute path. Simply Easy Smaller < 1Kb
## Problem
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
```javascript
const mysql = require('../../../../db/mysql')
```
Those suck for maintenance and they're ugly. [link](https://gist.github.com/branneman/8048520)
## Install
```javascript
npm install abrequire --save
```
## How to use
```javascript
global.use = require('abrequire')
```
or
```javascript
const use = require('abrequire')
```
## Example
```
-root
--app
----db
------mysql.js
------mongoose.js
----routes
------group
---------subGroup
------------router.js
--server.js
--node_module
--package.json
```
When `router.js` require `mysql.js` relative path
```javascript
const mysql = require('../../../../db/mysql')
```
When `router.js` require `mysql.js` absolute path
```javascript
const use = require('abrequire')
const mysql = use('app/db/mysql')
```
## Authors
* **Nonthachai Korninai** - [Github](https://github.com/7elven)
## License
This project is licensed under the MIT License