+ 3

Learning Node js in visual studio code and I encountered a Reference error " myname is not defined "

functions1.js (file 1) const myname = () => { console.log(" Hello"); }; module.export = myname; app.js (file 2) const sayname = require('./functions1'); myname(); Reference error : myname is not defined

17th Dec 2019, 1:47 PM
Namash Aggarwal
Namash Aggarwal - avatar
11 Answers
+ 8
It's module.exports not module.export Check out the test here: https://glitch.com/~simple-node-test1
17th Dec 2019, 4:36 PM
Calviղ
Calviղ - avatar
+ 5
Calviղ wow, it truly solved my problem, so kind of you . Now, I can move forward in my learning. I'm really thankful to you. I wish you a happy coding and a beautiful day ! 🌹🌹🌹💖
17th Dec 2019, 4:52 PM
Namash Aggarwal
Namash Aggarwal - avatar
+ 3
Try sayname(); in app.js instead
17th Dec 2019, 3:15 PM
Calviղ
Calviղ - avatar
+ 3
Namash Aggarwal May the force be with you. 🌟🚀
17th Dec 2019, 4:56 PM
Calviղ
Calviղ - avatar
+ 3
"function1.js :" const myname = () => { console.log ("Hello"); }; module.exports = myname; "app.js": const sayname = require("./function1.js); sayname(); //I hope it works
18th Dec 2019, 9:04 AM
Sarthak
Sarthak - avatar
+ 1
no ./ in require
17th Dec 2019, 3:15 PM
Gordon
Gordon - avatar
+ 1
Calviղ TypeError : sayname is not a function
17th Dec 2019, 3:19 PM
Namash Aggarwal
Namash Aggarwal - avatar
+ 1
Gordon "Module_Not_found"
17th Dec 2019, 3:21 PM
Namash Aggarwal
Namash Aggarwal - avatar
+ 1
Sarthak 🇳🇵 Thanks brother 🤝🤝
18th Dec 2019, 10:27 AM
Namash Aggarwal
Namash Aggarwal - avatar
0
رعد
18th Dec 2019, 10:18 PM
رعد رعد
رعد رعد - avatar
0
كقخخ
18th Dec 2019, 10:23 PM
رعد رعد
رعد رعد - avatar