How to create full path with node's fs.mkdirSync?

后端 未结 22 1877
故里飘歌
故里飘歌 2020-11-29 18:03

I\'m trying to create a full path if it doesn\'t exist.

The code looks like this:

var fs = require(\'fs\');
if (!fs.existsSync(newDest)) fs.mkdirSync         


        
22条回答
  •  既然无缘
    2020-11-29 18:24

    This feature has been added to node.js in version 10.12.0, so it's as easy as passing an option {recursive: true} as second argument to the fs.mkdir() call. See the example in the official docs.

    No need for external modules or your own implementation.

提交回复
热议问题