今天调试nodejs代码,一直报 cb is not a function,查阅官方文档,原来是async 新版本(“async”: “^2.0.0-rc.4”,)将cb参数挪到了后面:[code]async.auto({
// this function will just be passed a callback
readData: async.apply(fs.readFile, ‘data.txt’, ‘utf-8’)
showData: [‘readData’, function (results, cb) {
// results.readData is the file’s contents
// …
}]
}, callback);[/code]将代码参数互换,问题解决。