const {execSync} = require('child_process');
try{
const result = execSync(`du -sh "\Users\hites\Downloads\1.1 Node Project1 - File Explorer.zip (1)\Node Project1 - File Explorer"`).toString();
console.log(result);
}catch(err){
console.log(`Error: ${err}`);
output:::
'du' is not recognized as an internal or external command,
operable program or batch file.
node:child_process:903
throw err;
^
Error: Command failed: du -sh "C:\Users\hites\Downloads\1.1 Node Project1 - File Explorer.zip (1)\Node Project1 - File Explorer\static\code"
'du' is not recognized as an internal or external command,
operable program or batch file.
at checkExecSyncError (node:child_process:826:11)
at execSync (node:child_process:900:15)
at calculateSizeD (C:\Users\hites\Downloads\1.1 Node Project1 - File Explorer.zip (1)\Node Project1 - File Explorer\lib\calculateSizeD.js:8:27)
at C:\Users\hites\Downloads\1.1 Node Project1 - File Explorer.zip (1)\Node Project1 - File Explorer\lib\mainContent.js:55:57
at Array.forEach (<anonymous>)
at buildMainContent (C:\Users\hites\Downloads\1.1 Node Project1 - File Explorer.zip (1)\Node Project1 - File Explorer\lib\mainContent.js:31:11)
at Server.respond (C:\Users\hites\Downloads\1.1 Node Project1 - File Explorer.zip (1)\Node Project1 - File Explorer\lib\respond.js:72:29)
at Server.emit (node:events:390:28)
To get this running, you can simply run that in wsl (Windows Subsystem for Linux) assuming you have that installed and assuming that the version of wsl/linux you use with that has du. Worked for me. You would have to revise your path so you're using /mnt/c/... instead of C:\...