0.0.2 • Published 7 years ago
node-use-require v0.0.2
node-use-require
Node require 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:
const mysql = require('../../../../db/mysql')Those suck for maintenance and they're ugly. link
Install
npm install node-use-require --saveHow to use
global.use = require('node-use-require')or
const use = require('node-use-require')Example
-root
--app
----db
------mysql.js
------mongoose.js
----routes
------group
---------subGroup
------------router.js
--server.js
--node_module
--package.jsonWhen router.js require mysql.js relative path
const mysql = require('../../../../db/mysql')When router.js require mysql.js absolute path
const use = require('node-use-require')
const mysql = use('app/db/mysql')Authors
- Nonthachai Korninai - Github
License
This project is licensed under the MIT License