Skip to content
Advertisement

Tag: fs

Node.js: fs.existsSync doesn’t work on Heroku

I have a Heroku app using Node.js and Express, and I want to determine whether or not a certain file exists. However, it seems like the file is never found. I have the following path: The directory structure of my project looks like this: I am doing something wrong here? Or is this a Heroku issue? Answer Ok, I needed

Create big json object js

I am using Nodejs to Create a JSON file from a really large JSON object (1GB). In order to avoid memory problems, I’m using createWriteStream : After using Builder(custom function ) it will return a big object JSON. the final step is to create this file : but unfortunately, JSON.stringify cannot be used with such heavy Object JSON.stringify throws RangeError:

How to safely write multiple files at once?

I’m trying to write multiple audio files from URL at once in node.js. Here’s a code that seems to work, but I’m not sure if this is a safe way to do it since there are many asynchronous callbacks in a for loop. Is this safe to use this code? If not, how can I fix it? ADDED: Or is

How to read and open two different files in nodejs?

I have observed in this code that we can’t open the file after we have readFile. The computer complains about Error [ERR_STREAM_WRITE_AFTER_END]: write after end Of course if I remove the readFile function then this error goes away but I want to understand why this error is occurring even though I am using two different files for reading and opening.

nodejs – replace a string everywhere in a large file

I have some huge files which are difficult to read in memory. I need to read each line and then replace double quotes if found and edit the same file. Right now, I am reading the file line by line, storing in an array and overwriting the same file. But, that’s giving memory issue for big files. Any pointers ?

Recursively read a directories with a folder

I’ve been trying to request a recursively read a directory with fs module. I had problems along the way, its only giving me a file name. Here’s how I need it to be: File name. And also a directory of that file. This results may be as an object or bulked into an array. Anyone please help. Thanks. Answer Here

Advertisement