74951/how-to-create-a-directory-if-it-doesn-t-exist-using-node-js
Is this the right way to create a directory if it doesn't exist. It should have full permission for the script and readable by others.
var dir = __dirname + '/upload'; if (!path.existsSync(dir)) { fs.mkdirSync(dir, 0744); }
Hello @kartik,
Try:
var fs = require('fs'); var dir = './tmp'; if (!fs.existsSync(dir)){ fs.mkdirSync(dir); }
Hope it helps!!
To know more about it, enroll in Node.js training today.
Thank You!!
Hello @kartik, It's particularly useful if you're concerned ...READ MORE
Hii, You can create an HTTP GET request and pipe ...READ MORE
Hello @kartik, To print stacktrace of Error in console in ...READ MORE
Hello @kartik, The minimal setup for an HTTPS ...READ MORE
Hello, In the error callback or $.ajax you have three ...READ MORE
Hello @kartik, If your script is called myScript.js ...READ MORE
Hello @kartik, Try this code : // Create an ...READ MORE
Hello @kartik, Use node-inspector from any browser supporting WebSocket. Breakpoints, ...READ MORE
Hello @kartik, Try this: var fs = require('fs'); var dir ...READ MORE
Hello @kartik, nodejs v10.12 now supports this natively ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.