node javascript set variables in a plugin that will be used whenever the plugin is required
<p>I'm trying to create a plugin that I can set variables for, so that when the plugin is required the variables within the plugin are already set.</p>

<p>ie.<br>
<em>index.js</em></p>

<pre><code>var plugin = require('plugin');
plugin.setPluginValue('AwesomeValue');
</code></pre>

<p><em>anotherPage.js</em>  </p>

<pre><code>var plugin = require('plugin');
alert(plugin.getPluginValue())
</code></pre>

<p>-><code>AwesomeValue</code></p>

<p>When I try to do this, I only get partial functionality. For example, if I'm using the plugin for a webpage, and I go to a page where the value is set, and then called, everything works. But if I try going to another page without setting the value, I would get undefined.</p>

<p>EDIT Example Code</p>

<pre><code>var pluginValue
export function setPluginValue(newPluginValue){
 pluginValue = newPluginValue;
}
export function getPluginValue(){
 return pluginValue;
}
</code></pre>