Node.js create folder or use existing

后端 未结 14 1455
暖寄归人
暖寄归人 2020-12-04 06:43

I already have read the documentation of Node.js and, unless if I missed something, it does not tell what the parameters contain in certain operations, in particular fs.mkdi

14条回答
  •  佛祖请我去吃肉
    2020-12-04 07:26

    You can use this:

    if(!fs.existsSync("directory")){
        fs.mkdirSync("directory", 0766, function(err){
            if(err){
                console.log(err);
                // echo the result back
                response.send("ERROR! Can't make the directory! \n");
            }
        });
    }
    

提交回复
热议问题