Node.js create folder or use existing

后端 未结 14 1445
暖寄归人
暖寄归人 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:40

    You can also use fs-extra, which provide a lot frequently used file operations.

    Sample Code:

    var fs = require('fs-extra')
    
    fs.mkdirs('/tmp/some/long/path/that/prob/doesnt/exist', function (err) {
      if (err) return console.error(err)
      console.log("success!")
    })
    
    fs.mkdirsSync('/tmp/another/path')
    

    docs here: https://github.com/jprichardson/node-fs-extra#mkdirsdir-callback

提交回复
热议问题