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

553
Views
I am not able to make files using fs.writeFileSync() in Node.js, idk why?
const fs = require('fs');
const folderName = process.argv[2] || 'Project'


fs.mkdirSync(folderName)
fs.writeFileSync(`${folderName}/index.html`)
fs.writeFileSync(`${folderName}/style.css`)
fs.writeFileSync(`${folderName}/app.js`)

This is the error I am getting when I execute:
node boilerplate.js Portfolio

the folder "Portfolio" is made but not the files😓

error

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Have you looked at the documentation for fs.writeFileSync?

It says fs.writeFileSync(file, data[, options]) – the brackets denote optional parameters and that means only options is optional, so you must always pass in file and data.

You aren't passing data, and the error message alludes to that with undefined.

If you want empty files, pass in an empty string as data.

fs.writeFileSync(`${folderName}/index.html`, '')
fs.writeFileSync(`${folderName}/style.css`, '')
fs.writeFileSync(`${folderName}/app.js`, '')
about 4 years ago · Juan Pablo Isaza Report
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!