For individual dirs:
var fs = require('fs');
var dir="./tmp";
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
Or, for nested dirs:
var fs = require('fs');
var dir="./tmp/but/then/nested";
if (!fs.existsSync(dir)){
fs.mkdirSync(dir, { recursive: true });
}
More Related Contents:
- NodeJS require a global module/package
- npm install private github repositories by dependency in package.json
- npm ERR cb() never called
- Node – was compiled against a different Node.js version using NODE_MODULE_VERSION 51
- How to make node.js require absolute? (instead of relative)
- Why does “npm install” rewrite package-lock.json?
- Node.js – Maximum call stack size exceeded
- Firebase cloud functions is very slow
- MongoDB/Mongoose querying at a specific date?
- node.js – Is there any proper way to parse JSON with large numbers? (long, bigint, int64)
- Expressjs raw body
- Making mongoose.js queries run synchronously
- Watch a folder for changes using node.js, and print file paths when they are changed
- How to populate a sub-document in mongoose after creating it?
- mongoose custom validation using 2 fields
- Mongoose delete array element in document and save
- Puppeteer in NodeJS reports ‘Error: Node is either not visible or not an HTMLElement’
- Assigning a domain name to localhost for development environment
- How to wrap a buffer as a stream2 Readable stream?
- Getting HTTP headers with Node.js
- MongooseError – Operation `users.findOne()` buffering timed out after 10000ms
- Microsoft Bot framework: Sending Message on connect
- how to use populate and aggregate in same statement?
- Automatically remove referencing objects on deletion in MongoDB
- Mongoose nested query on Model by field of its referenced model
- What the scenario call fs.close is necessary
- Nodemailer/Gmail – What exactly is a refresh token and how do I get one?
- Node.js – Mongoose – Check if a collection exists
- Firestore Add value to array field
- Can I access a cookie from Socket.io?