JavaScript fs.readFile
ajayprashar (1)


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);

You are viewing a single comment. View All
TheDrone7 (989)

@ajayprashar instead of import fs from 'fs';
Try using const fs = require ('fs');
If it still doesn't work, try adding it using the package manager.