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

//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

我用nodejs环境试验了没有错

可能是你的汉字编码把
你试试把这个文件的编码弄成utf-8
然后再把
//student.js这些没用的注释删除掉

就ok 了

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

这里的定义写错了哦
因为你使用了
exports.add = add;
所以要写成这样
var add = function(student){
console.log(student);
}

后面的那个teacher中的写法是一样的哦