Most voted "fs" questions
15 questions
Sort by count of
-
2
votes2
answers149
viewsFile deletion with Fs not working
I have a if to delete a file, however it is not being deleted and is not throwing errors. Does anyone have any idea? if (results[0].photo != `arquivos/imgpadrao.jpg`) {…
-
2
votes1
answer70
viewsCount of new lines in Node
I wish to count the number of new lines of a file. For this I am doing as follows the reading of the file : const fs = require('fs')//utilizando o módulo fs…
-
2
votes1
answer32
viewsWhat is the real difference between Fs.readFile() and Fs.createReadSream()?
The point is that I can use both functions to do the same thing. For example: const fs = require('fs') const path = require('path') const filePath = path.join(__dirname, '../arquivo.txt')…
-
2
votes2
answers215
viewsFs.writeFile() is overwriting a file
I am writing a script using Node.JS that checks how many points a customer has in their registration, and I need that every purchase above 150 real that he makes, the point increase by 1, when you…
-
1
votes1
answer2620
viewsHow to check if file exists (asynchronous)
In Node.JS, I use this method of fs to check if a file exists: const fs = require('fs'); // [...] if (fs.existsSync(path)) { /** Do stuff. */ } The question is, how can I do the same thing, but in a…
-
1
votes1
answer780
viewsHow to list files in a directory and use in an Angular2 + Webpack project
Hello, I am creating a project in Angular2 + Webpack and in this project I use as a design library @angular/material. So I can create my own icons using SVG, I’m extending the component MatIcon as…
-
1
votes0
answers23
viewsJS: Problems with the order of a Dates array
Hello! I’m having trouble in Javascript with the order of an array. Basically, I take a list of objects and sort it according to one of its attributes which is a Date. But when I give a console.log,…
-
1
votes1
answer53
viewsArray is empty outside the function scope even though it is declared in the global scope
I’m starting in Javascript and Nodejs and I’m not able to understand pq even I declare an array in the global scope, when I try to access it outside the functions where I made the map the array…
-
1
votes1
answer46
viewsJSON replacing information with the same name
I want to record two or more names in a JSON file. However, when I try to do this, it saves only the last information. My job: async function grava_login(){ fs.writeFile("data.json",…
-
0
votes0
answers118
viewsFs.Promises does not exist
I was setting up an app when I came across the following mistake: The interesting thing is that I use the same function in another application and it works normally. I wonder if you have ever come…
-
0
votes1
answer100
viewsJavascript function making nodemon run in loop
I made a function that works when run from node app.js, but when I run with Nodemon it starts and reboots forever. The function in question is used to write a JSON to a file. I need to use Nodemon…
-
0
votes0
answers14
viewsHow to pass the value of a client variable to a Node.JS server?
I am developing an application that will need to replace an XML via FS, and all the contents of that XML is stored in a variable that is created by JS in the client after pressing a button. I need…
-
-1
votes1
answer56
viewsHow can I write to a server file using Node FS?
The command is running on my server machine: $ http-server . -p 3333 Everything perfect when accessing from a web browser to another machine (also Linux). But when running this script on Node, I…
-
-1
votes1
answer217
viewsTreat File as String in Nodejs
I am having the following problem : I wish to carry out the count of line breaks, ie the amount of '\n' in a file. For this, I wish while reading the file to treat it as a String. I am trying it as…
javascript node.js filing-cabinet fs newlineasked 4 years, 8 months ago Gabriel Ribeiro Carneiro 81 -
-2
votes1
answer47
viewsHow not to repeat information in a js Node file
You guys, I got this comic: const fs = require('fs'); const produto = { nome: 'Smartphone', preco: 1749.99, descontoo: 0.15 } fs.appendFile('mynewfile2.txt', JSON.stringify(produto), err => {…