stormZeng
stormZeng
2016-04-18 04:29

下面这么简单的2个nodejs文件哪里错了??啊

  • node.js

//student.js

function add(student) {
console.log(student);
}

exports.add = add;

.................................................................................(分割线)

//teacher.js

var student=require('./student');

function add(teacher) {
console.log(teacher);
}

student.add('小明');

add('张老师');

而控制台的错误提示:

TypeError: student.add is not a function
at Object. (D:\LearnTools\Sublime Text 3x64\Project\Nodejs-test\s
chool2\teacher.js:9:9)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:146:18)
at node.js:404:3

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答