Created
April 22, 2020 09:37
-
-
Save janniks/8507925554cccf48df12c889b313accf to your computer and use it in GitHub Desktop.
03 - A Better Way to Import Local Node.js Modules - An Article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const projectRoot = require('app-root-path'); | |
const random = require(projectRoot + '/somewhere/deep/and/random.js'); | |
// OR using .require | |
const requireLocal = require('app-root-path').require | |
const random = requireLocal('somewhere/deep/and/random'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment