3,190 questions
1
vote
1
answer
68
views
How to decide between fs.readFile(), fs.readFileSync(), and fsPromises.readFile()?
According to the documentation on Reading files with Node.js, there are three ways to read the full contents of a file in memory and return its content: fs.readFile(), fs.readFileSync(), and ...
0
votes
1
answer
70
views
Does fs.watch in Node.js listen to changes in hidden folders like .git?
If I watch a directory that has a .git inside of it and run fs.watch, does that listen to changes within .git folder?
For example if I use:
fs.watch(dir, { recursive: true }
0
votes
0
answers
80
views
WRTC connection failure on sending binary
I am working on an electron pet project of mine to send files over local network.
For the actual sending part I choose to use wrtc via Simple-Peer, and it's on a backend(maybe weird I know) so I ...
-5
votes
1
answer
131
views
Why is arr undefined even though function returns an array? [duplicate]
const randomGIFFunc = async function(dirname) {
const dirPath = 'src/gifs/' + dirname;
fs.readdir(dirPath, (err, files) => {
if (err) {
console.log('Error reading directory: ', err );
...
3
votes
2
answers
566
views
How to fsync a directory?
I have a write-ahead log that stores some metadata using atomic renames. Currently I am only fsyncing the file before rename, but it is my understanding that I should also be fsyncing the directory ...
0
votes
0
answers
48
views
How to mount a subdirectory(inode ) to a specific path? Kernel development
I'm working on a directory-level snapshot feature based on a file system, where a snapshot of a directory is recorded by an inode, and I want to implement how the snapshot sharing mount should be ...
0
votes
1
answer
94
views
How does the close event handler for a readable stream in node.js get called?
I'm having trouble understanding the following code:
const fs = require('fs')
const readableStream = fs.createReadStream(__filename)
readableStream.close()
readableStream.on('close', () => {
...
1
vote
0
answers
35
views
Nodejs birthtime.getTime() of fs module works locally but not in production [duplicate]
I am trying to the select the most recently created file from an array of files. This works just fine on my local node environment on mac, however when I push to my production server instead of ...
0
votes
0
answers
75
views
Node.js fs.symlinkSync EPERM on Windows 10 without admin privileges
I’m running Node.js v14.17.0 on Windows 10 (Build 19042) as a normal user. I’ve enabled Developer Mode so that creating symlinks shouldn’t require elevation, but whenever I try:
const fs = require('fs'...
0
votes
0
answers
111
views
pm2 windows service cannot access network drive in nodejs
I’m facing an issue with a Node.js application that uses the fs module to read files from a network drive on Windows. The app works fine during development, but when I run it as a PM2 service, it ...
0
votes
1
answer
64
views
Why Can This Not Write To Directory 'Output'?
I am attempting to write a file to an existing directory, using node, path, and fs.
How it's supposed to work:
Init mock data.
Loop through mock data.
Write mock string to existing directory 'output'
...
3
votes
1
answer
371
views
Error packaging electron app that uses local files
I created an App using electron that interacts with local files using IPC. When i run it using npm start, éverything works as excpected, but when i try to package the app into an .exe file using the ...
1
vote
1
answer
89
views
fs.writeFile adds extra brackets to json of key=>values object in node.js
I'm trying to update one JSON file in a for loop called asynchronously. Each time I update the whole file, with 1 object.
This is my very complex code after half a day of research. (I know it's too ...
0
votes
1
answer
110
views
Is there a way to open, save and close an excel file (.xlsx)?
I've got a daily automated function in nodejs which builds and populates an excel spreadsheet via the package xlsx-populate, which has been running for a couple of years now with no problems.
A ...
1
vote
0
answers
68
views
Can Nodejs fluent-ffmpeg process opus file stream in async way?
What I want to do:
load a large opus file
processing it using fluent-ffmpeg
output a stream for further use (realtime output is required)
Runnable codes(file path needs to be changed):
const fs = ...
1
vote
1
answer
56
views
How do I send big files in nodejs from the client to the server without an "Uncaught out of memory" error?
When sending a big file, such as one over twenty megabytes from the client to the server using a fetch request, the HTML page with the file input freezes for about 10 seconds and gives the error in ...
0
votes
2
answers
66
views
Why does fs.link() fail with EPERM whre fs.rename() succeeds?
I want to serve some static files under the directory /var/www I would like to swap in a new set of files (which exist as, for example, /var/data/example) every few days or so. The server does not ...
0
votes
2
answers
69
views
Use npm library in React Native, when it imports fs
I understand that I cannot simply use fs in React Native as in Node. However, my situation is a bit different. Here's a simple representation of my problem.
Library:
const fs = require('fs')
function ...
0
votes
1
answer
83
views
fs.watch doesn't return an FSWatcher instance in Electron
I have an Electron React App
Where I'm trying to call .close() on the object that I assigned an fs.watch to. But I think Vite, Electron or something is wrapping something around the object returned ...
0
votes
1
answer
89
views
Convert file of consts to string and save it in fs
I'm newbie with electronjs so i tried to save my file as a TXT file via fs like this:
simple consts in
data.ts file:
export const users = [{ id: 1, name: 'a', classId: 1 }]
export const classes = [
...
2
votes
1
answer
365
views
How to get rid of warning "lint TP1004 fs.existsSync(???*0*) is very dynamic" in nextjs 14.2.5 server
Using nextjs 14.2.5, in one of the server component, I need to save a temp file to server storage, the code works fine, but every time the server component is called, there's the this warning
lint ...
0
votes
0
answers
70
views
How to create file in AWS codecommit?
I am creating a project. This project will log payment details when a payment is created.
import * as fs from 'fs/promises';
import * as path from 'path';
app.use('/files', async (req, res) => {
...
0
votes
1
answer
51
views
Why don't folders delete in gulp tasks? [duplicate]
This task work ok. I use path ".wwwroot/css/site.min.css"
var gulp = require("gulp");
const fs = require('fs').promises;
gulp.task('clean', async function (done) {
try {
...
0
votes
1
answer
54
views
Discord.js fs.writeFile not updating the correct json
I am using discord.js to write a bot. I am using a json called data in order to hold information that can be changed via slash commands. However, using fs.writeFile doesn't modify the targeted json.
...
0
votes
0
answers
69
views
Is there a standard way for unique file content per user in Javascript
I am running a server in which users get a javascript file when they sign up. They can use this on their website, and I can track it.
So people register through my expressjs project, but to change the ...
0
votes
0
answers
79
views
Correct way to have several async processes in nodejs append to the same file
Is there a correct / better approach to using a file descriptor that several process running asynchronously can write to? e.g.:
const allTheAsyncJobs = []
const fileDescriptor = fs.openSync(pathToFile,...
1
vote
1
answer
307
views
Read from nth row in csv typescript
I am trying to read a csv file from 4th row, in my csv file first 3 rows contains some meta data in column1. But the actual number of columns in csv is 6.
eg:
metadata1
metadata2
metadata3
head01,...
1
vote
1
answer
2k
views
Am I overlooking the solution to "Module 'fs' has been externalized for browser compatibility"?
Just so you get an understanding of the situation, I am trying to build a web game library that runs on my computer. It is pretty much a rip off of the Nintendo Wii and 3DS. I'm using Vite as the ...
1
vote
0
answers
192
views
Loading file list in Next.js does not reflect the latest changes
In Next.js, I implemented a feature to fetch a list of files in a specific directory using a module like fs.
When I deployed it, the functionality itself worked fine, but when I took actions such as ...
1
vote
0
answers
69
views
docker container can not save/mapping file folder to host
I have Node Server inside Docker, inside server, I have upload file function, which save file to /uploads.
Here is the success code which help me make the file in this folder :
app.post('/uploadFile',...
0
votes
0
answers
52
views
Cannot read a double nested directory
Essentially I'm trying to store all of file system in a certain dir in an array of objects. Here is my code:
type Cache = {
path: string;
content: Buffer;
};
const readdir = (dir: string, ...
2
votes
1
answer
923
views
How to handle multipart/form-data file using nextjs?
I have being trying to upload image from frontend to backend but cannot workaround my head over this.
Frontend
Send some data including "image" to backend.
Backend
Below is my backend code
//...
0
votes
0
answers
69
views
How to read a file from url with Node.js and Electron
How can I read a file with nodejs, even json, from url?
My file is on a server. I tried with ftp download but it is very inefficient.
Now is working on this, but is very slow for download and running.....
0
votes
1
answer
2k
views
Module not found: Can't resolve 'fs' in nextjs
In my project there is an one dependency better-sqlite3.
This dependency is working fine.But after some time i am getting the fs module not found error again and again.
I tried all the methods like ...
0
votes
0
answers
76
views
Login page HTTP request sends infinitely
A few hours ago i made a similar question but i was addressing the wrong issues.
the real problem is, i have this functional login function:
async function entrar() {
const user_name = ...
0
votes
0
answers
66
views
Node.js fs.existsSync returning false postives
I have the following code:
const fs = await import("fs");
let hashedPassword;
if (!fs.existsSync(".fs")) {
fs.mkdirSync(".fs");
console.info("...
-1
votes
1
answer
45
views
nodejs rewrite file segment
In nodejs, how do I overwrite a section of a file without creating additional files or reading all the data into memory?
let filename= '123.txt';
const fd = fs.openSync(filename, 'w+');
fs.writeSync(...
0
votes
0
answers
55
views
How to read program files' content in NodeJS
My goal is to make an array of file content from a directory. The directory can resemble a project with source code like Python, JS, etc. So far I have it loop through an array of every file in the ...
0
votes
1
answer
67
views
How to wait till all compressed files are extracted
For the below posted code in section code-1, I extract the contents of .tar file to a specific path. Then I want to rename the the extracted files as shown in the code.
The number of extracted files ...
1
vote
1
answer
1k
views
How to get node fs to work in an Angular and Electron application
" The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this ...
0
votes
0
answers
89
views
How to extract and write contents of tar file to disk
I make RESTAPI call to an endpoint, and I receive the response in the following format
<Buffer 4d 4d 00 2a 00 00 00 08 00 13 01 00 00 03 00 00 00 01 01......
what i am receiving is tar file ...
1
vote
1
answer
72
views
How to get tar contents out of a hexa representation
I make RESTAPI call to an endpoint and I expect to receive .tar contents. But what I received is
<Buffer 4d 4d 00 2a 00 00 00 08 00 13 01 00 00 03 00 00 00 01 01......
The method connectForTar ...
0
votes
1
answer
144
views
Node fs file does not exist
I have the following code to read a file in my project with Node fs.
const files: FileSystemTree = {
"Component.tsx": {
file: {
contents: fs.readFileSync(
...
0
votes
1
answer
190
views
Node file system fs.writeFile() throwing error in JavaScript module
In my index.mjs file I have a function that concatenates and minifies JS utility files. I have it set up like this:
import fs from "fs";
import { minify } from "terser";
function ...
0
votes
1
answer
52
views
Difference between two blocks of code involving fs.writeFile() in Node.js
I am trying to declare a POST method for a RESTful API using node and express. I need to accept the request body and write it onto a JSON file that I'm using to store my users data. I am using the fs ...
0
votes
1
answer
70
views
Error: Why can't I display an image on the frontend?
I am trying to get an image and data from MySQL and send it to the front end as JSON and display the content in HTML. In MySQL, I have the path of the image, and I print it with fs as you well see in ...
0
votes
0
answers
160
views
Why NodeJS fs module won't read or write to visible folder shared on the network?
I'm scaling my NodeJS app (on Windows 11) and need to setup additional workstations (Windows 11 aswell).
Right now I simply need a shared folder, so I created one and made it visible on the network. ...
-1
votes
1
answer
176
views
Iterate through a ReadDir and append file names to an array in Rust
I am trying to use the fs::read_dir() and iterate through the results and append all file names to an array. Something like this, except this isn't working:
let mut result: Vec<&str> = Vec::...
0
votes
0
answers
22
views
fs.readdir give no results and no errors
Here is my function (which should rename the newest file of a given directory, if the file has a type of extension) :
const fs = require('fs').promises; // Note the .promises
function renameLatestFile(...
0
votes
2
answers
4k
views
How to update a JSON file for a Playwright test
I have a JSON file that contains a value that I need to update as a step of a Playwright test as well as containing other values that need to remain unchanged. I have found a solution but it's not ...