3,196 questions
0
votes
0
answers
104
views
Node File System unstable
In Node.js, I noticed that file operations were not always stable. I have the impression that fs gives up when the operations are not completely finished. Here is an example to illustrate:
"use ...
1
vote
1
answer
1k
views
Parse a log file into json object
I have log file named request.log this is the content of the log file
[2022-06-30T09:56:40.146Z] ### POST https://test.csdf/auth/send_otp
{
"method": "POST",
"...
0
votes
0
answers
271
views
this is impossible to inculde fs library [duplicate]
here i want to use fs library at the js file to create and edit a json file. but whenever i include this namespace an strange error comes up.
if i use
var fs = require("fs")
it throws the ...
0
votes
1
answer
267
views
How to read file names and display names to window node js
I'm wondering how I'd be able to read file names from my directory and be able to display them in table form to a window. I already have an attempt I made below but for some reason whenever I run the ...
-1
votes
2
answers
304
views
async with fs file is not saving
I have this code:
(i need to use async because this function may be used multiple times per second, so file won't be saved without async)
var fs = require('fs').promises;
async function stater(amount){...
1
vote
1
answer
1k
views
How to find tmp folder made by nodejs filesystem?
I was using fs to write values from textarea into a file and had issues with the path until I found on stackoverflow that the path has to be a tmp folder. I did that and the terminal shows the ...
0
votes
2
answers
789
views
How to write multiple lines to a text file in a loop?
Within a javascript function, I'm taking in a list of events and for each event, I would like to write text to a file. I have provided the correct
// Code within another function
events.map(event =>...
0
votes
0
answers
24
views
I want to write log file for AngularJS project. How can I do it? [duplicate]
I tried this method :
var fs = require("fs");
//or try
//var fs = require("file-system");
var cont = " selamm \n";
fs.writeFileSync("read2.txt", cont, { flag: 'a' },
err => {
});
...
-2
votes
2
answers
1k
views
how to upload file from frontend and post it in a local folder using fs and express [duplicate]
I think I should use fs but I am not pretty sure how
ejs:
<form action="/products" method="POST">
<input type="file" name="image" id="image">
<button class="submit">Submit<...
2
votes
1
answer
6k
views
Node.js: [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
I'm trying to make a discord bot that saves images sent to it into a folder, and I'm getting this error:
TypeError: [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an ...
0
votes
1
answer
309
views
fs.readdirSync alternative for my Web-App
I have a big problem and I hope someone can help me.
Some time ago I created a "Desktop App" with Electron, consequently, I was able to freely use the "file-system" library but now ...
1
vote
1
answer
22
views
ERR_HTTP_HEADERS_SENT caused by response to POST request after refresh node.js Express. res.send inside fs.watch callback
On my webpage user can enter text and press send. this causes the server to append the message to a json object stored in a file. when this file is altered it then sends the new json to the client.
...
0
votes
0
answers
1k
views
Moving directories with subdirectories using `moveSync` from `fs-extra`
I have 2 paths:
app/consultants/pages/assignments
app/consultants/pages/consultants
Both paths contain subdirectories and files.
I created a reduce function that returns an array of objects with the ...
0
votes
1
answer
241
views
How do I modify JSON files while keeping the state updated?
If I have a program as follows to modify a JSON file:
var fs = require('fs');
var dt = require('./dataWrite.json');
console.log("before",dt);
fs.readFile('./data.json', 'utf8', (err, data) =&...
0
votes
1
answer
314
views
What's the equivalent to chattr in the rust standard library?
I need to execute the equivalent of chattr +i myfile.txt in rust.
Since the call for chmod is fs::set_permissions()
I was expecting something like fs::set_attributes() to also exists, but I cannot ...
-1
votes
1
answer
111
views
fs writes file with web image link instead of the image itself
I am using node's module fs.
When I run the following code:
return new Promise((resolve, reject) => {
if (!fs.existsSync(`./${imageDescription}`)) {
axios.get(imageUrl).then((...
0
votes
1
answer
1k
views
Use fs promise to move a file
I have a nodeJS app server-side that receives files.
The user sends a file from the client and I want to make several operations, one of them being moving the file to the final destination. I used to ...
1
vote
0
answers
275
views
Multer - chunk argument not valid
I have a problem with stream.pipeline()
await pipeline(
req.file.buffer,
fs.createWriteStream(
`${__dirname}/../client/public/profil/${fileName}`
)
)
I have this error
TypeError [...
4
votes
1
answer
21k
views
Uncaught TypeError: Failed to resolve module specifier "fs". Relative references must start with either "/", "./", or "../"
When I try to import the fs module in my own module like import * as fs from 'fs' the following error in the browser console comes:
Uncaught TypeError: Failed to resolve module specifier "fs"...
0
votes
2
answers
182
views
I am trying to take two different files and sum the data
So I wrote this fs function to read files data from a file:
const fs = require("fs");
const read = function (file) {
fs.readFile(file, "utf8", (err, data) => {
if (err !==...
2
votes
1
answer
798
views
fs.writeFile (node) adds information on an already existing file instead of replacing this
I made a code to write a file using fs and node-cron to run this every x minutes. I get the data the first time, but in the next job I get the data added again in the file and the old one too, I wan ...
0
votes
2
answers
798
views
read all the file and store in object format in node js / javascript
I wrote a code which help me to read all the folder file and make me store them in array format so my code looks like this
readAll.js
module.exports = readAllFile = () => {
const arr = [];
fs....
1
vote
0
answers
382
views
fs.copyFileSync doesn't do anything
I'm using Node.js to copy a few files for one of my packages. My OS is Windows 10 Pro. When I run the JS file (tried in cmd, powershell and cmd with admin) absolutely nothing happens. No error, no ...
0
votes
0
answers
115
views
How can you write to an Object File from JavaScript?
I have a string with hexadecimal code for an object file I have generated in a program previously in my JavaScript file. How can I create an object file with this code, preferably with the fs module?
...
0
votes
0
answers
15
views
How to wait for the callback to be finished with fs.readdir? [duplicate]
I'm using fs.readdir callback function to do stuff in a path file but i want to wait for the callback to be finished to continue on with the rest of my code.
const get = async(path_files) => {
...