Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

554
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda