2

I am trying to use module.exports() to create a new module in my NW.js application.

I have two files that I am using:

Index.js

const gkm = require('gkm'); //This is a key listener
const AudioStreamMeter = require('audio-stream-meter'); //This is a mic listener
const exportable = require("./twitchAuth.js");

exportable.test();
// More code under this

twitchAuth.js

function doSomething() {
    document.getElementById("volume").style.backgroundColor = "#FFF";
}

module.exports(doSomething);

only thing is that when I add const exportable = require("./separateFile.js"); to index.js then gkm and audio-stream-meter stop working as well as the rest of my code.

View the full source code here

bocodes
  • 387
  • 1
  • 4
  • 12

1 Answers1

2

I created a PR to fix a bunch of stuff in the repo:

the main issue here though is that module.exports is not a function, it would be assigned an object, such as:

module.exports = { doSomething };

And your paths for importing aren't relative to the CWD

const exportable = require("../app/twitchAuth.js");
Jaredcheeda
  • 1,657
  • 17
  • 15