I'm new to blockchain and currently developing small application for educational purpose using solidity. I am using truffle framework and stuck at a point.
currently there is only one app.js file in the project, I want to create another js file and import that file in app.js just like classes in java.
for ex:- If I write register_user() function in example.js file, then how should I import that file in app.js so that I can call functions from example.js.
I've tried using 'module.exports = function(){};'
but it throws error as Uncaught ReferenceError: module is ./example.js not defined
please help !!!
app.js
, you should do something likeconst example = require("./example.js");
. Of course, this is under the assumption that both files are located in the same folder. If they are not, then you should use the relative path ofexample.js
when you import it inapp.js
. – goodvibration Mar 2 '19 at 11:46Uncaught ReferenceError: module is ./example.js not defined
– Shubham Naphade Mar 2 '19 at 15:56