JavaScript fs.readFile function
ajayprashar (1)

My name is Ajay and I am new to JavaScript. I have a question I was hoping you could help me with:

How do I access the function 'fs.readFile' from within node within

import fs from 'fs';

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

Thank you,

You are viewing a single comment. View All
Answered by eankeen (1209) [earned 5 cycles]
View Answer
eankeen (1209)

@ajayprashar Hmm. I would not. Oversimplifying, runs their Node processes on Linux. And Linux uses forward slashes. I would consider using path.join() to ensure that it works both on your Windows machine and on replit. Something kind of like path.join(__dirname, 'ipromise.txt') instead of G:\\DATA...ipromise.txt.

To do this you need to import the path module

let path = require('path');