3,196 questions
0
votes
0
answers
40
views
heroku doesn't let me create a file even temporarly
i just discovered that Heroku uses an Ephemeral File System, so i opted to use AWS S3 to store images and upload them. the problem i encountered is creating the file to upload it.
my app is built with ...
0
votes
1
answer
517
views
next js api returns no response after deployment
while working on the local host, api and the posts.jaon file also works fine. was able to perform CRUD.But after I deploy it to vercel, the api does not loads.
error in the log is something like this:
...
0
votes
0
answers
68
views
writefilesync not writing all variables to a json file
I have this code:
circular = () => { //fix circular stuff for json.stringify
seen = new WeakSet();
return (key, value) => {
if (typeof value === 'object' && value !== null) {
...
0
votes
1
answer
31
views
Is the a way to cancel/not list directories/files which can't be read anyways because of lacking permission by fs.readdirSync?
A way to filter out those directories which need administration permission.
fs.readdirSync(currentPath, { withFileTypes: true }).forEach(element => {
....
})
Still shows all directories. Even ...
0
votes
2
answers
166
views
How do properly chain these .then statements so they resolve in the correct order?
The assignment I'm working on is to design a Node.js program that presents the user with command line prompts and writes a well-organized README markdown file with the input. The prompts are created ...
0
votes
2
answers
121
views
Node/express - cancel multer photo upload if other fields validation fails
I have multer as middleware before editing user function. The thing is that multer uploads photo no matter what, so I am wondering if there is a way to somehow cancel upload if e.g. email is invalid. ...
0
votes
0
answers
29
views
Create a file then add an arbitrary text using fs functions in node js
Is there a reason why this code doesn't work? additionally using node file.js responds MODULE_NOT_FOUND.
const fs = require('fs');
// Create the "text.txt" file with the content "hello ...
0
votes
1
answer
950
views
Core Node.js module "fs" Not Found when @fastify/static deployed on render.com
It is my understanding that the core modules, like "fs" are part of the node.js build, and no special configuration is needed to make them available for importing, so I'm at a loss as to how ...
0
votes
1
answer
791
views
Type 'ReadStream' is not assignable to type 'string'.ts(2322)
I am trying to run the following code:
const uploadParams = {Bucket: bucketName, Key: '', Body: ''};
const file = '/home/a/bars/img1.png';
const fileStream = fs.createReadStream(file);
fileStream.on('...
1
vote
3
answers
7k
views
create file on folder if not exists on node js
I want to creat directory if not exist and then save the file that I got from Front-end
This is my code and it only does the part of creating folders, but my main problem is saving the file in this ...
1
vote
2
answers
7k
views
Read multiple files from directory with Node.js using Promises/Async/Await
I'm trying to scan a local directory for all of the text files within it, then read each of those files. I want to do it properly using promises, async, and await, but something is going wrong and am ...
0
votes
1
answer
147
views
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 ...
0
votes
1
answer
81
views
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 ...
1
vote
0
answers
51
views
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)
....
0
votes
1
answer
38
views
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 ...
1
vote
0
answers
27
views
I have a problem with chaining functions while resizing an image and displaying it in the browser according to the URL params
I'm a total beginner with backend, node and express I'm trying to build an api that resize the image according to the entered params in the URL and render it in the browser using typeScript, so I'm ...
2
votes
1
answer
270
views
Use url link instead of path to file in Node JS
I have a requirement to process a file in node to extract some text from that file, my issue is since i am new to node, i don't understand how to pass the path to the file. I am using cloud Function ...
0
votes
1
answer
517
views
fs.writeFile corrupting json files
I have a program that writes a lot of files very quickly, and I noticed that sometimes there will be extra brackets or text in json files sometimes.
Here is how the program works:
There is an array of ...
0
votes
0
answers
133
views
Getting MaxListenersExceededWarning NodeJS - Need help troubleshooting
I'm still new to NodeJS and am getting a MaxListenersExceededWarning: Possible EventEmitter memory leak detected message when I call the following function:
function zipUpFile() {
const folderPath = ...
0
votes
0
answers
117
views
Expose different modules for different build targets (electron app vs. web)
I have an app that I want build as an Electron app (using electron-builder) or build for deployment to a web server. With the Electron app, I have the app (from inside the Electron renderer) read and ...
1
vote
0
answers
517
views
Nest, serverless: ENOENT: no such file or directory, open
My project has above project structure
src
---- Clone(empty folder)
---- app.module.ts
---- app.service.ts
serverless
functions:
main:
timeout: 60
handler: src/...
0
votes
2
answers
480
views
how to log data into a new file?
I'm a beginner to node.js, started to learn just a few days ago. i'm trying to log the listener's data into a new file by using fs.appendFile, but no matter how many times i try to change the code, it ...
0
votes
0
answers
293
views
How to read .dmp file in node.js
I am trying to read the .dmp file using nodejs Filesystem but it is not working.
Can someone please help me
fs = require('fs')
fs.readFile('test.dmp', 'utf8', function (err,data) {
if (err) {
...
1
vote
1
answer
570
views
fs.readdirSync(__dirname) showing .js file extension instead of .ts
I have the following code:
console.log(fs.readdirSync(__dirname));
Which prints out the following:
[ 'index.js', 'objective.js', 'quest.js', 'user_objective.js' ]
However, my file directory setup is ...
0
votes
1
answer
91
views
Node https server crashing: `undefined` path in fs.readFile()
I'm setting up an https server but as soon as I access the root / the service crashes (after retrieving the html file successfully). The error is generated as per the debugger in the fs.readFile ...