Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
fs.copyFileSync doesn't do anything

I'm using Node.js to copy a few files for one of my packages. My OS is Windows 10 Pro. When I run the JS file (tried in cmd, powershell and cmd with admin) absolutely nothing happens. No error, no copy. Here's the code:

#! /usr/bin/env node
let fs = require("fs");
let path = require("path");

let rootPath = path.join(__dirname, "..");

let root = fs.readdirSync(rootPath);

let exclude = [
    ".git",
    ".gitignore",
    ".prettierrc",
    "bin",
    "node_modules",
    "dist",
];

root = root.filter((item) => exclude.indexOf(item) === -1);

let rootFiles = root.filter((item) =>
    fs.statSync(path.join(__dirname, "..", item)).isFile()
);

let rootFolders = root.filter((item) =>
    fs.statSync(path.join(__dirname, "..", item)).isDirectory()
);

for (let file of rootFiles) {
    let filePath = path.join(rootPath, file);
    let destinationPath = path.join(process.cwd(), file);

    if (!fs.existsSync(filePath)) {
        fs.copyFileSync(filePath, destinationPath);
    }
}

process.exit(0);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!