Saturday, 13 May 2017

How to get a variable from a JS file to a node JS file

So essentially what I'm trying to do is get a variable from my app.js file to my run.js file. The app.js file handles everything client related, and the run.js handles server side stuff. So I've tried using 'export' and 'require' but that still doesn't seem to be helping because I keep getting this error...

ReferenceError: module is not defined

This is essentially what I've tried to do, the currentUser in the app.js is already defined.

//app.js
module.currentUser = currentUser;

//run.js
var myApp = require('./app.js');
var user = myApp.currentUser;



via Elmer.V

No comments:

Post a Comment