Answers for "node js get directory path"

9

read directory in node js

const testFolder = './tests/';
const fs = require('fs');

fs.readdir(testFolder, (err, files) => {
  files.forEach(file => {
    console.log(file);
  });
});
Posted by: Guest on April-09-2021
0

get current path nodejs

console.log("Current directory:", __dirname);
//OR
console.log("Current directory:", process.cwd());
//OR
const path = require("path");

const directoryName = path.basename(__dirname);
console.log(directoryName);
Posted by: Guest on March-24-2022
0

node get path of current file

module.filename
Posted by: Guest on February-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language