Access MainView.js from another .js

I have a functions.js file

functions.js:

var utils         = require("utils");
var main         = require("MainView");

i have no problems accessing “utils.js” functions but i get an error when i try to access “MainView.js” in Monitor:

module not found: MainView

how can i access data/functions in MainView.js ?

Can you post more about your file structure?

i have all files in root.

utils.js MainView.js MainView.ux functions.js

if i remove the “require(“MainView”)” from functions.js everything works fine but of course i cannot access MainView.js functions:

utils.js:

function one {
 ...
}
   module.exports = {
    one: one
}

MainView.js:

function two {
...
}
module.exports = {
    two: two
}

functions.js:

var utils     = require("utils");
var main     = require("MainView");

solved:

it seems i had to add it to the MainView.ux to be able to use it in function.js:

<JavaScript File="MainView.js" ux:Global="main" />

thnx!

Glad you got it working :smiley: