Require plain text files, like any .js or .json file.
This is a dirty hack and the API this functionality depends on (require.extensions) is deprecated! The module loader API is frozen, so it will probably never be removed, but it may be unstable or have some weird quirks. Also, the number of filesystem calls node.js has to make to require any module grows linearly with the number of registered file extensions!
Do not - I repeat - do not use this in production. You have been warned.
$ npm install require-txt
$ yarn add require-txt
First, register the handler:
Then, just require your files:
console;// "Hello, how are you?"
You can pass custom file type extensions:
That's pretty much it.