node.js - Does the second parameter `options` exists for `readdir` function in `fs` module? -


when pass "utf8" second parameter readdir function in fs module (https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback), gives following error:

fs.js:78 throw new typeerror('callback must function'); ^ 

see following snippets:

snippet #1

var fs = require("fs"); fs.readdir(process.argv[2], "utf8", function(){     console.log(arguments); }); 

snippet #2

var fs = require("fs"); fs.readdir(process.argv[2], function(){     console.log(arguments); });  

snippet #1 throws error, while snippet #2 works.

why happen? doesn't readdir function have second optional parameter?

you might running older version of node.js.

v5 , previous did not support passing options. https://nodejs.org/docs/latest-v5.x/api/fs.html#fs_fs_readdir_path_callback

this added in v6.0.0.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -