+ 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
11 Answers
+ 8
It's module.exports
not module.export
Check out the test here:
https://glitch.com/~simple-node-test1
+ 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 ! 🌹🌹🌹💖
+ 3
Try
sayname(); in app.js
instead
+ 3
Namash Aggarwal May the force be with you. 🌟🚀
+ 3
"function1.js :"
const myname = () => {
console.log ("Hello");
};
module.exports = myname;
"app.js":
const sayname = require("./function1.js);
sayname();
//I hope it works
+ 1
no ./ in require
+ 1
Calviղ TypeError : sayname is not a function
+ 1
Gordon "Module_Not_found"
+ 1
Sarthak 🇳🇵 Thanks brother 🤝🤝
0
رعد
0
كقخخ