CommonJS模块没有设置variables的值?

我在主文件中的init()函数工作得很好,但是当我把它放入一个单独的模块并且需要它时,显然它停止工作。 我在控制台中得到这个错误

 Uncaught TypeError: Failed to set the 'value' property on 'AudioParam': The provided float value is non-finite. 

看起来这可能是它的同步问题? 我怎样才能解决这个问题?

 //init.js file var initt = function () { octaveNumber = document.getElementById("octaveNum"); audioCtx = new (window.AudioContext || window.webkitAudioContext); osc = audioCtx.createOscillator(); volume = audioCtx.createGain(); filter = audioCtx.createBiquadFilter(); osc.connect(filter); volume.connect(audioCtx.destination); booleanVal = false; osc.frequency.value = dial.value osc.start(); gainDisplay.innerHTML = gainSlider.value; noteSetOscFreq() octaveUpClick() octaveDownClick() waveFormSelector() } module.exports = initt; 

主要的js文件:

 if (!localStorage.getItem("presetsArr") { messages(); 

但是,当我不使用模块,只是把相同的initt函数在If语句中,它工作得很好。 如果模块依赖于主js文件中的variables,是否需要在模块中需要我的主jsfile? 就像我在我的initt()模块中调用其他函数一样。 这是好的做法吗? 这是我第一次使用模块系统。