나는 Nodejs의 초보자입니다. 지금, 나는 가지고 module.js
Nodejs 모듈에 대한 오류
function Hello()
{
var name;
this.setName=function(thyName){
name=thyName;
};
this.sayHello=function()
{
console.log("hello,"+name);
};
};
module.exports=Hello;
및 getModule.js
var hello = require("./module");
hello.setName("HXH");
hello.sayHello();
하지만 실행하면 나는 오류 가지고
d:\nodejs\demo>node getModule.js
:
d:\nodejs\demo\getModule.js:2
hello.setName("HXH");
^
TypeError: Object function Hello()
{
var name;
this.setName=function(thyName){
name=thyName;
};
this.sayHello=function()
{
console.log("hello,"+name);
};
} has no method 'setName'
at Object.<anonymous> (d:\nodejs\demo\getModule.js:2:7)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
왜 I 나는 가이드를 따라 간다.
미안 해요, 난, 감사 부주의했다! – HXH