¡GoConqr estrena diseño! Cuéntanos qué te parece.

Módulo 14 de 22 · Multimedia

Read from a file

Kostas Diakogiannis

Read from a file

Read a file's contents

Now we have imported the fs module, we can work with files. Let's create a .txt file inside the same folder, and fill it with some text and save the file. 

We will try to read the contents of this file and log it to the console through node.js.

For that purpose we will use the fs.readFileSync function, which accepts the path of the file as an argument, and then we will log it's contents as it's shown above.

This is the synchronous way, that means that while the execution of the reading is taking place, our whole script is blocked and can't execute further.

Instrucciones

Para avanzar en el curso, envía un intento de este test. Puedes enviarlo después de la última pregunta.

Ir al módulo elegido

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?