Questions tagged [node.js-fs]

203 questions
-1
votes
1 answer

nodejs can not detect .pem file

I have a kubernetes typescript file and a .pem file under same parent directory in vscode, but i got error error: ENOENT: no such file or directory, open './cert.pem', it seems like my ts file can not detect pem file exists const…
xx11
  • 1
  • 1
-1
votes
2 answers

How could I read a file in fs without the file extension

How could I read a file in FS without having to put the file extension. e.x: fs.readFile(../hello**.png(without this file extension?** Tried this and this returned not found.
-1
votes
1 answer

NodeJS - How to wait until fs.WriteStream is closed

I have some code that I need to wrap with mine, the original code is creating a WriteStream this way - function createLog() { this.stream = this.fs.createWriteStream(this.logFilePath, {flags: 'a'}); this.stream.write('log content'); …
Meir Tolpin
  • 325
  • 2
  • 13
-1
votes
1 answer

Why does using toString('binary') on a Node.js buffer give strange characters?

I have something similar to the following code: const fs = require('fs'); const imageBuffer = fs.readFileSync('path/to/image.jpg'); const binary = imageBuffer.toString('binary'); console.log(binary) Which gives something…
Jack
  • 397
  • 4
  • 13
-1
votes
1 answer

Dynamic Input to a .txt file with Node.js fs

I have this code, and I am trying to get the data from the function addrBlk to display in console through fs.writeFile. I have tried with this code with these params and this function to display ```let addrBlk = (name, address1, address2, city,…
Dylan T
  • 139
  • 11
-3
votes
1 answer

NodeJS Split strings in a text file with :

I want to be able to read a file for example names.txt and for example in the text file on each line is NAME:LAST and it on each line. I want to split each so I can use NAME = {0} LAST = {1} Example…
SlickNick
  • 1
  • 1
-3
votes
1 answer

Can't resolve "fs" imported from ... importing custom package in Next.js

I am working in a monorepo, using bolt to manage package installation. I also use preconstruct in order to build exports which are compatible with both module and common js. With preconstruct I am using also babel. The monorepo folder structure…
-4
votes
1 answer

Keep watching a folder that contains *.js files

I want to keep watching a folder (Folder Name Js) that contains some .js and other extension files also. Now i want to perform an action whenever .js file changed / update TBH, i didn't tried anything. Although i can watch directory with fs.stat()…
RKS
  • 1
  • 3
1 2 3
13
14