Skip to content
Sign upLog in

JavaScript fs.readFile

Profile icon


My name is Ajay and I am learning JavaScript using

When I use the code below I receive the error that 'fs.readFile' is NOT a function. Does anyone know how to use this function within

import fs from 'fs'; let ourStuff = fs.readFile('G:\DATA\git\ipromise\ipromise.txt','utf8', callback); console.log(ourStuff);

You are viewing a single comment. View All
Profile icon

as I said, use const fs = require ('fs'); which is the traditional JavaScript syntax instead of the new import statement that is not supported everywhere.