title: How to use node-localstorage from browser extension which is using npm
body: <p>I am new to extension development. Right now I am testing a Firefox extension developed with the Add-on SDK. I want to use HTM5 localstorage to store something from one of the background scripts in my extension, which will be fetched from a different background script of the same extension. npm (Node Packet Manager) has been used, so the problem is I am not able to use browser localStorage object, <code>ReferenceError: localStorage is not defined</code> is what I get. </p>
  
  <p>By surfing I came to know about node-localstorage. I am following the instructions from 
  <a href="https://www.npmjs.com/package/node-localstorage" rel="nofollow">https://www.npmjs.com/package/node-localstorage</a>.  But, when I test my extension with the given code in the link above, I get an error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Message: Module `localStorage.js` is not found at resource://gre/modules/commonjs/localStorage.js
  
  Stack: 
  module.exports@resource://xxx-at-xyz-dot-com/scripts/Somescript.js:3:23 
  @resource://xxx-at-xyz-dot-com/index.js:6:11
  run@resource://gre/modules/commonjs/sdk/addon/runner.js:147:19
  startup/&lt;/&lt;@resource://gre/modules/commonjs/sdk/addon/runner.js:87:9 
  Handler.prototype.process@resource://gre/modules/Promise-backend.js:933:23
  this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:812:7
  this.PromiseWalker.scheduleWalkerLoop/&lt;@resource://gre/modules/Promise-backend.j s:746:1 –
  </code></pre>
  
  <p>Here is an approximation of how I was trying to use localStorage:</p>
  
  <pre class="lang-js prettyprint-override"><code>//Somescript.js (background script)
  
  module.exports = function () {
      this.watchTab = function (tabId, port, url) {
         //some code
         localStorage.setItem("key","value");
         // some code
      }
  }
  </code></pre>
  
  <p>The line <code>localStorage.setItem("key","value")</code> throws an error <code>ReferenceError: localStorage is not defined.</code> This is the reason I am not able to use localStorage.</p>