Questions tagged [node.js-fs]
203 questions
0
votes
0 answers
How to add properties to the global variable from the loop when working with asynchronous fs.readFile function?
I get nothing in result object, because it's executed earlier than readFile.
But anyway, I want to find a way to add all properties to the global object and then add it all into the .json file.
const fs = require('fs');
const PATH =…

tmormand
- 1
- 2
0
votes
1 answer
No winston log files are created during pre-run check
I have a typescript project using winston and winston-daily-rotate-file. At the start of the project I check for environment variables that are present. If not, I want to log the missing variable using logger.error(). But for some reason the error…

HotFix
- 157
- 1
- 11
0
votes
1 answer
fs mkdir/copy intermittently fails in protected directory, despite having permissions
I have an electron app on Mac with full disk permissions. I am using fs to make a directory in a protected folder, and copy files from a temp folder to the new directory.
When using fs.copy, I periodically get two different types of errors:
If the…

leuenn
- 11
- 3
0
votes
0 answers
Save a Gzip object into file
I have a Gzip object stored in a variable.
However, I want to save that to a file.
This file is Gzip object (not stream, string or buffer).
function(params) {
const gzipObject = params.Object;
// save this to a file
…

Rishabh Aryal
- 32
- 5
0
votes
1 answer
S3 putObject isn't uploading my file to S3 from EFS using nodejs Lambda
I have a use case where I have to move a zip file from EFS to S3 using NodeJs Lambda function. I am ready data using fs.createReadStream. It is creating a zip file on EFS and when I try to move that file to S3 using putObjectCommand it doesn't…

Rehan CH
- 109
- 1
- 11
0
votes
0 answers
Problem with fsPromises.readFile used in module
I use XMLHttpRequest in Node.js and when handling request in server.js (asynchronous POST request) I use this code:
const filePath = './input.pdf';
fsPromises.readFile(filePath)
.then(res => {
const pdfBytes = new…

Vladimir Shestakov
- 11
- 1
0
votes
0 answers
Differences between 2 React node apps
I am trying to integrate 2 react apps I have been working on into 1 new react application (all created using npx create-react-app nameofapp) but I can not get the libraries I have used in the previous app to load/work in the new application even…

user1092538
- 33
- 3
0
votes
0 answers
How to write the unit test for 'fs unlink' using vitest for the follow function?
deleteDuplicatedImage.ts
import { unlink, PathLike } from "fs";
import { logger } from "../libraries";
export const deleteDuplicatedImage = (imagePath: PathLike) => {
unlink(imagePath, function (error) {
if (error) {
throw error;
…
0
votes
1 answer
First function runs after second function that needs data from previous
I am trying to load json data for a small project of mine, but when I run loadDefs (the function meant to save the data to the Game class) it seems to run fs.readFile before checking wether file_data has been modified.
loadDefs(file_path:any)
{
…

MisterZig
- 3
- 2
0
votes
1 answer
NestJS & fs writeFile not working as expected
So, when i try to upload a file via NestJS FS and Socket.io with Angular, it gives an error:
Error: EISDIR: illegal operation on a directory, open 'CDN/attachments/63aea8c5e37c6b1242a6973f/63aea86fe37c6b1242a6970a/20230112140045/'
at…

Almaszosz
- 42
- 7
0
votes
1 answer
Module not found: Error: Can't resolve 'fs' . Read the details first
I've been building a basic weather api with React and TypeScript. I have utilized "npx create-react-app . typescript" for the setup. After building out my application I started it up. Initially I had success contacting the api however as I tried to…

user19568466
- 11
- 4
0
votes
0 answers
Discord.js fs level system adding } at ends of .json
I'm currently working on a discord bot that includes an economy and a level system.
When user levels up, he should get beans (currency).
The level system works so far, but when I start the add bean code, a } is placed at the end of my user.json and…

Sven10 Sven
- 1
- 1
0
votes
0 answers
how to fix TypeError: require(...) is not a function in fs discod.js v14
hello I had command handler in discord.js v14 its hosted in replit I opened my replit today after 3weeks and getting this error. Below is my index.js if want you can join my repl to help but please help me fix it as I have to get the bot on top.gg…

Mohammad Zohaib Ur Rahman
- 27
- 1
- 7
0
votes
0 answers
Node (express, fs) streaming multiple large videos
I am building a server that serves a video to a user. The server works as expected, but when I try to switch to a different video (going to different URL), the previous video continues to play (i have more explanation). I can't use HTML because…

Dfr
- 31
- 8
0
votes
0 answers
Fluent-ffmpeg Invalid data found when processing input error only when the second request is received
I am using Node.js for backend to use ffmpeg. To use ffmpeg, I adopted fluent-ffmpeg. This is working perfectly except for one problem. That is when I send video from client side SPA(single page application) to the server-side for the "second" time,…