Questions tagged [node.js-fs]

203 questions
0
votes
1 answer

fs.writeFile corrupting json files

I have a program that writes a lot of files very quickly, and I noticed that sometimes there will be extra brackets or text in json files sometimes. Here is how the program works: There is an array of emojis with some more information, and if that…
floober
  • 13
  • 3
0
votes
1 answer

How can I use fs with webpack 4.46.0?

I, am trying to use the fs module but I get this error Module not found: Error: Can't resolve 'fs' in '/home/pau/Escritorio/Master/Blockchain/Prac2/PRAC2_Template/Ejercicio_2/app/src' @ ./src/index.js 5:11-24 I have fs installed and for what I've…
P00
  • 11
  • 4
0
votes
0 answers

Next.JS use fs module in a component that is not directly rendered

My goal is to display code beautifully using prismjs on a next.js application. My code is stored in a data folder locally. I use react-syntax-highlighter and fs-extra npm packages. fs cannot be used directly because it doesn't work in the browser…
0
votes
0 answers

Getting MaxListenersExceededWarning NodeJS - Need help troubleshooting

I'm still new to NodeJS and am getting a MaxListenersExceededWarning: Possible EventEmitter memory leak detected message when I call the following function: function zipUpFile() { const folderPath = "./dist"; const zip = zlib.createGzip(); …
0
votes
0 answers

wait for a file to save then run the next line? (Node js)

In an api point I want to save a qrcode as png in local file system then in the same api I want to get that saved image and use it to make a pdf file. But in the function the pdf making function is running before saving the file in the file system.…
Manas S. Roy
  • 303
  • 1
  • 10
0
votes
2 answers

Read or select value names from .json file to push in the array

if myjson.js file data: { "key1": [ { "name1": [ "word1", "word2", ], "name2": [ "word3", "word4", ] } ] } loaded: var jsonData = fs.readFileSync("myjson.json", "utf8"); const…
emss
  • 65
  • 9
0
votes
0 answers

Error: ENOENT with correct file path when using node:fs

I am trying to read data from a json file but I get Error: ENOENT even though from what I can see, the file path has been written correctly. The code I am running: const fs = require("fs"); const testing = require("./test.json") console.log("yes")…
DIron
  • 3
  • 1
0
votes
0 answers

Expose different modules for different build targets (electron app vs. web)

I have an app that I want build as an Electron app (using electron-builder) or build for deployment to a web server. With the Electron app, I have the app (from inside the Electron renderer) read and write from the FileSystem (using Node's FS). I…
Dr. Vortex
  • 505
  • 1
  • 3
  • 16
0
votes
2 answers

how to log data into a new file?

I'm a beginner to node.js, started to learn just a few days ago. i'm trying to log the listener's data into a new file by using fs.appendFile, but no matter how many times i try to change the code, it keeps giving me an ERR-INVALID-CALLBACK. const…
eggyolk
  • 1
  • 1
0
votes
0 answers

JEST error EACCES: permission denied, mkdir

I'm working on a Typescript Rest API with Express, that I run on a linux machine, and in one of my middleware in charge of uploading files, I create a folder in the public folder with a specific ID as a name. It's working all fine until I run my…
0
votes
0 answers

How to read .dmp file in node.js

I am trying to read the .dmp file using nodejs Filesystem but it is not working. Can someone please help me fs = require('fs') fs.readFile('test.dmp', 'utf8', function (err,data) { if (err) { return console.log(err); } …
Neha
  • 15
  • 4
0
votes
0 answers

Invalid image from a base64 string

I receive an image in base64 from my nodejs express server like so: fs.writeFileSync("image.png", tensor); const readStream = fs.createReadStream('image.png'); readStream.pipe(res); This is what I see in the console on the client. Then I try…
0
votes
1 answer

Reactjs read text file line by line using fs

With reactjs, I tried to use fs to read a text file line by line, but then the compiler complains "Module not found: Error: Can't resolve 'fs'. I browsed the internet, it's well known reactjs bug for webpack 5, people asked to go down to webpack…
user7087799
  • 73
  • 1
  • 9
0
votes
0 answers

How to use the fs module in Electron?

I am trying to use the fs module in my Electron app to copy and edit files, however it does not work in any way. I have a schedule.js file where I want to have methods to copy files. I tried adding const fs = require('fs'); and using fs.copyFile()…
0
votes
0 answers

I am trying to read a file using fs readFile but im getting no return

When i use fs.readFile() on a characters.json file that i created through fs.writeFile() i dont get any errors or return. Characters.json: ["Monkey D. Luffy","Roronoa Zoro","Nami","Usopp","Sanji","Tony Tony Chopper","Nico…