Gaurav Shukla
Gaurav Shukla

Reputation: 560

async.parallel: Type Error, task is not a function

What is wrong with this code ?

async = require("async");
fs = require("fs")

async.parallel(['calc.js','index.js'], fs.stat, function (err, results) {  
if (err){
console.log(err);
}
else{
    console.log(results);
}
});

When I try to run this little peice of code, I get the error mentioned below -

/home/gaurav/node-exp/node_modules/async/dist/async.js:4819
        task(rest(function (err, args) {
        ^

TypeError: task is not a function

I was following a nodejs tutorial and I am very new to node js so pardon me if the question is very naive

Upvotes: 0

Views: 1023

Answers (1)

Kushagra Gour
Kushagra Gour

Reputation: 4966

What you are trying to do is map the file names onto fs.stat. You missed the call to map function in your code.

async.map([file1, file2], fs.stat, function () {...

Upvotes: 1

Related Questions