I am having an issue with a JSON file in which there are strings of characters attached to many of the field names. This is making it difficult for me to target those objects in JS. The structure looks like this: "bk:ParentField": { "bk:Field": "Va ...
I am facing a challenge in writing an array to a CSV file using the node's fs module. Every time I attempt this, new columns are created due to the commas within the array elements. How can I ensure that the array remains contained within a single col ...
This NodeJS project involves starting the server with npm start. The project reads files from a folder called "./mydir/" using 'fs.readdirSync'. It then pushes these files into an array and prints them on the console. var fs = require('fs ...
Attempting to remove a basic folder that contains another nested folder, such as: /tmp/ac6c1fcaeae0c7ec4d1a8/res. Here is the code I am using: module.exports.deleteFolder = (path) => { try { if (fs.existsSync(path)) { console.lo ...
Is there a way to trigger the close function from window.onbeforeunload even when closing the app through 'right click' -> 'close window'? It seems that this.close() is not working in this scenario, possibly due to scope issues. The listener is meant to h ...
During my attempt to copy a large number of files within a folder using "ncp", I've encountered an issue where not all the files are successfully copied. After checking, it seems that some files are consistently missing. I resorted to using fs.readdi ...
Currently running on Node version 8.11.2 A fairly simple CSV export feature has been implemented. This function receives an array of objects and dynamically creates the file headers based on the properties of these objects. const csvExport = (dataList, f ...
I have set up a node/express server that sends the ajax-start.html file. Within this file, there is a script that enables ajax requests to be made to the server. Everything functions correctly in this setup. However, I am looking to enhance this process by ...
My current task involves generating a file from a URL using the fs module to my local system. Initially, everything seems successful. However, when attempting to post this file into a group using the createReadStream() function, I encounter an issue where ...
Is there a way to read the content of a file (either a txt or CSV file) that a user uploads without saving it to local storage? I know I can save the file in an upload directory and then read it from storage. However, I'm wondering if there is a way to di ...
One of the server’s features is a caching engine that stores all accessed files within a main directory. I am considering implementing Chokidar to monitor the entire directory tree (including subdirectories) for any changes in files, and automatically ...
As I embark on my journey of creating my first nodejs app, I encountered an error when attempting to transfer a portion of my code to an external JavaScript file. The specific piece of code I am trying to move is the mongodb schema declaration: var mongoo ...
I am currently working on a piece of code that involves fs.writeFile. The goal is to update the localdata.json file whenever a new workout is POST'ed to the database. This code takes data from the local state and attempts to write it into the file. U ...
This code snippet is functional: var promise = new Future(), dirs = [], stat; Fs.readdir(Root + p, function(error, files){ _.each(files, function(file) { //stat = Fs.statSync(file); //if ( s ...
Struggling to access the data within a directory of files, I've encountered an issue where the data doesn't seem to be read correctly or at all. Even though there is content when opening the files individually, when attempting to examine their contents pro ...
Currently, I am in the process of developing a menu for my ReactApp that mirrors a folder structure. Each folder is categorized based on the documents it contains, with some folders having sub-folders and files nested within them. The desired output shoul ...
I've established a websocket connection where I save the contents of each received message to a JSON file. However, if I receive two or more messages in the same second, it doesn't save properly. How can I prevent this issue? Each time I receive ...
I have successfully implemented the following function on my node.js localhost: // index.js const scrape = require('website-scraper'); const PuppeteerPlugin = require('website-scraper-puppeteer'); const path = require('path'); ...
I have been working with NextJS and have successfully used the getStaticProps functionality in previous projects to populate data. However, I recently set up a new NextJS project and it seems that this functionality is no longer working. When starting th ...
I am facing a challenge with replacing specific text strings in a file. I have two arrays - one containing the strings that need to be located and replaced, and the other containing the replacement strings. fs.readFile("./fileName.L5X", "utf8", function( ...
My approach to file management involves storing files in Amazon S3 while also maintaining a local file cache. To optimize efficiency, I want to prioritize checking the cache before accessing any file. I aim to utilize promises and streams in my implementat ...
Is there a way to efficiently manage multiple Node.js processes writing to the same file using fs.createWriteStream without overwriting data? By default, when fs.createWriteStream is called, it clears out the file. I aim to clear the file once and only app ...
Looking for a solution to save a URI-data string as a jpg on the server using only Javascript. The alternative of writing it to a canvas and reading the image from there is not ideal. Any ideas? ...
Question about Node.js file directories I'm currently facing an issue with a code snippet I found on Stack Overflow that recursively retrieves all files in directories using Node.js. Even though I have implemented the provided solution, I am struggli ...
const express = require('express'); const upload = require("express-fileupload"); const editJsonFile = require("edit-json-file"); const fs = require('fs'); const app = express(); app.use(upload()) app.use(express.url ...
I have a basic web application that I am currently developing using Node.js and Express. This is a breakdown of my package structure: https://i.stack.imgur.com/D7hJx.png The entries in my questions.json file are outlined below: [ { "question": "Wh ...
As I was working on my DiscordJS Bot project, I encountered an issue regarding returning a png file saved in my local folder using FS. The bot is able to navigate through folders smoothly, but the challenge lies in returning the actual file rather than j ...
Hey there, I'm encountering an issue in Chrome debugger where it says 'fs.readFileSync is not a function' when I try to use readFileSync(); This is how I set it up... const fs = require('fs'); I then proceeded to execute the function... let content = f ...
I have a question about extracting file types or extensions from a folder. I have multiple files in a folder, and I want to retrieve the type/extension of the file that matches a randomly generated number stored in my num variable. Is there a way to achiev ...
As someone new to test-driven development, I am currently working on creating an automated testing suite for my application. While I have managed to write tests that confirm the data retrieved from a successful call to Node's fs.readFile method, my c ...
I'm looking to develop a log module for my app that will automatically create a new file based on the time it is initialized (when the init function in the module is called). However, I keep encountering an error when trying to create the new log file usi ...
Essentially, I have multiple search strings provided by the client that need to be matched with each line in a file. If a line matches all of the inputted strings, I should add that line to the results array. However, when I run the code below, it only ret ...
I'm currently in the process of developing my own npm package/framework for personal use, and one of the features I want to include is the automatic creation of a specific set of files and folders. Initially, I thought this would be a relatively strai ...
My node.js script is named Index.js and I also have another file called bot.js. How can I execute the bot.js file using Node.js? var fs = require('fs'); const commandFiles = fs.readdirSync('./users/commands').filter(file => file.endsWith('.js')); fs ...
I've been working on a script to delete an entry from a JSON file. The JSON file structure includes an array of users like this: { "users": [ { "username": "test1", "answers": [ "Red", "Blue", "Yellow", " ...
I used to have a node.js express server up and running on my previous server. However, after migrating to a new server, the code seems to have stopped functioning. Let me share the setup of my server: var fs = require('fs'); var express = requi ...
I have been utilizing Cypress to run tests on my Electron application. Due to Cypress operating in browser mode, the FS module is not compatible. As a result, I am encountering this error: Error in mounted hook: "TypeError: fs.existsSync is not a func ...
Recently, I encountered a challenge while trying to utilize Resemble.js in a node environment. Despite some initial complications with installing canvas/cairo due to OS X Mavericks/XQuarts and Homebrew issues, I eventually succeeded. After making signific ...
Reading a file line-by-line in NodeJS typically involves calling readline.createInterface, and then attaching event handlers for line and close. It's interesting how the reader seems to start on its own without any explicit trigger. How does it know ...
I am currently developing a Discord bot that pairs up two individuals for a game. This process involves storing their Discord ID, queue status, and opponent in a JSON file. Here is an example of how the data is structured for each user: { "discordId": ...
Here is the current code snippet: const fs = require('fs') fs.readdir('C:UsersEvaDesktopMainInput', (err, files) => { if (err) { console.log(err); return; } files.forEach(file => { fs.readFile(file, 'utf8', function (err, ...
I am struggling to figure out why I can't successfully display the JSON data on my webpage. As a newcomer to JavaScript, I am eager to showcase the contents of a JSON file within my index file. After utilizing the express generator for all my files, ...
I have a situation where I need to retrieve an image stored on the server and send it to the client using sockets. While I am able to display the received image on canvas, I am encountering difficulties in saving the image to the local disk. I have attempt ...
I recently created an electron app using Node.js and encountered a peculiar issue that I am unable to resolve: Below is the object that I passed as input: { lessons: [ name: "math", scores: [90, 96, 76], isEmpty: false ] } ...
Currently, I am attempting to utilize node js in order to read a csv file. Below is the code that I have written: fs.readFile(config.csvUploadPath, function read(err, data) { if (err) { throw err; } console.log(data + 'my data&apo ...
Currently, I am attempting to access a file from my local system using the 'fs' module in node.js. However, I have encountered an issue where the 'fs' module does not seem to function properly when an absolute path is provided. Here is the code snippet in ...
I am attempting to create my own database using JavaScript and JSON, but I have encountered some issues along the way. My main struggle is figuring out how to extract specific content from a JSON file. After doing some research, I came across this code sn ...
Currently working on a project in node.js that requires saving an uploaded file from a client onto a remote file server for later retrieval. While I'm familiar with accessing and storing files on the local file system using 'fs', I am unsure ...
In my log file titled request.log, the following entries are present: [2022-06-30T09:56:40.146Z] ### POST https://test.csdf/auth/send_otp { "method": "POST", "headers": { "User-Agent": "testing&q ...
I have this large 70mb .csv file that I need to parse and convert into a json format. Initially, when I tested the conversion on a smaller 500kb test csv using regex, it was easy and worked out perfectly. However, when I attempted to apply the same proce ...
After creating a form that sends a POST request to /fUpload, I encountered an issue with the image upload route: router.post('/fUpload', function (req, res){ var form = new formidable.IncomingForm(); form.parse(req, function (err, fields ...
I am facing a challenge in deleting a file or folder based on a path that does not include an extension. Consider the path below: /home/tom/windows The name windows could refer to either a folder named windows OR a file named windows.txt Given that the ...
I'm currently developing a project in VUE that utilizes 'fs', and I have included my code below. async Upload(file){ let fs = require('fs'); console.log(file); console.log(this.dialogImageUrl); try { ...
I've been attempting to read data from a locally stored JSON file, organize it into individual JS objects, and add them to a queue. However, I'm struggling to find a way to test my parsing function to ensure it's functioning correctly. My current approach ...
I am currently working on verifying the accessibility of a specific file, folder, or directory for reading purposes. I have implemented the code below, which functions properly. However, there are a couple of aspects that I would like to inquire about: 1. ...
I'm trying to retrieve file names from a directory: const fs = require('fs'); fs.readdir("repo/_posts", (err, files) => { files.forEach(file => { res.write(file + "\n"); }); }) Even with only 15 files, ...