vajahath/lme

Can we make lme globally available?

Closed this issue · 3 comments

Issue

Currently, if we want to use lme inside a file, first we've to require it.

const lme = require('lme');

// use lme here

The issue with this is we've to require it in every file. Sometimes in my projects I forget to do the above step and simply use it without requireing it. Then this holly piece of err pops up

lme is not defined

Then I've to start requireing it. It feels like a burden if one see that err many times.

Proposed solution

I found a solution in this sof answer. I don't know if this is a good practice. Thus if we require('lme') at the very top of the very first file where node starts execution, that solves the issue. We can seamlessly access the lme variable under every module/file without requireing it. Like:

./app.js (let here is where node execution starts)

lme = require('lme');

// rest of the code
const express = require('express');
const hello = require('./hello');
...

./hello.js (let this be a sub module)

lme.s("It works..!"); // it really works

// rest of the code
...

Should we add this to the official documentation?

Fixed

I don't think we should encourage global intricacies like this. People can always research it on their own.

OK. Removed it from README.