Questions tagged [fs-extra]

73 questions
1
vote
2 answers

How to read json from different path in Nodejs?

When I had a very simple file structure without routers and controllers in my node express project, I can easily read and return properly the contents of a json file, using fs-extra. But when I added some folders to folders (and learned…
Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95
1
vote
0 answers

How can I make post request with an excel file?

I'm trying to send post request to url with an excel file that exists in a path but all the examples I tried tries to parse excel file. How can I send excel file as it is using the below code? This is the method static async…
1
vote
4 answers

.then() does not appear to be waiting for the previous .then()

I'm creating a process that converts multiple markdown files into a single pdf. It creates a pdf file for each .md file found in the source directory. Then it merges the individual pdf files into one pdf. It is this last step that is failing saying…
klequis
  • 427
  • 1
  • 6
  • 17
1
vote
2 answers

How to delete all txt files within directory NodeJs

I need to delete only the txt files within a directory (multiple levels). I'd hazard a guess that it's possible with fs-extra... https://github.com/jprichardson/node-fs-extra But I can't find a solution without specifying the individual file name.…
1
vote
2 answers

fs-extra: Copy files without overwrite

I am using copy method of fs-extra to copy files from a source to destination. My use case is to create a copy of the file with a name like if a file of the same name exists in the destination. The copy method of fs-extra module overwrites the…
Ravi Kukreja
  • 627
  • 1
  • 8
  • 17
1
vote
1 answer

How to copy multiple directories to one directory in Node

I'm looking for something like.. fs.copy([dir1,dir2], 'destDirString').then(() => { cb(); }); Is there an easy way to copy two directories' contents to another dir in Node? I have two NCP commands now, want to condense.
Union find
  • 7,759
  • 13
  • 60
  • 111
1
vote
1 answer

Why can't I delete the directory that I've created using fs-extra in Electron?

So I have a problem where after I create a directory in my windows computer, I'd like to delete the folder, but whenever i tried to delete the Folder this error come's out. So, here's my code, function createFolders(dir) { try { …
Annonymous177
  • 563
  • 2
  • 10
  • 21
1
vote
3 answers

NodeJS - How to copy one folder to another, overwriting only files that differ?

The question: How to copy one folder to another in NodeJS, overwriting only files that differ? About fs-extra "copy" method: It seems that the copy method from fs-extra does not have the option to skip identical files (that have not undergone any…
Paulo Coghi
  • 13,724
  • 14
  • 68
  • 90
1
vote
1 answer

`fs-extra` integrate with `bluebird ` got `Cannot read property 'then' of undefined` error

Here is my code var Promise = require('bluebird'); var fse = Promise.promisifyAll(require('fs-extra')); fse.remove('./myDir').then(function () { console.log('Remove myDir done.') }); I always get TypeError: Cannot read property 'then' of…
Chen Dachao
  • 1,736
  • 2
  • 21
  • 36
1
vote
2 answers

fs-extra copy file outputs blank file

When I run the following code a blank file gets created with the correct name. I clearly dont want a blank file. I know the path is correct because when i make it purposely incorrect it fails (obviously) const path = require('path'); const fse =…
Mike Fielden
  • 10,055
  • 14
  • 59
  • 99
0
votes
0 answers

How to append data to a JS file defining an object inside a specific object property?

I have an automated script (made in Node.js + TS) that creates some files automatically and replaces some template content depending on the user input. The thing is, I need to append data to a file after a specific content, but keeping its structure…
Unapedra
  • 2,043
  • 4
  • 25
  • 42
0
votes
0 answers

NodeJS - How to remove contents of a file from a specific point to another?

I'm trying to create a script that uses some template files and then replaces the contents of the file with some data asked to the user. I've been using the {{word}} pattern to be able to replace specific words, but I'd like to be able to remove…
Unapedra
  • 2,043
  • 4
  • 25
  • 42
0
votes
0 answers

Log4js issue: Cannot read property 'native' of undefined

Am using Log4js in my Reactjs app. I have downloaded log4js (v@6.8.0) with Node(v@16.14.0). After importing getting following error. Any issue with current version of Log4js?
Shankar Nanda
  • 129
  • 4
  • 11
0
votes
1 answer

having problems with `fs.writeFile` it doesn't create files

I'm trying to start a script that itself creates a model file in json using fs.writeFile. The problem is when I run the script using node file.js. It is supposed to create a new file face-expression-model.json in directory /models but it doesn't…
ImadAris
  • 15
  • 5
0
votes
0 answers

Copy ALL directories & files to new directory

Hi I'm trying to copy a folder to a new folder (recursively), I've found a working example however it only copies one child directory within the parent, the last directory to be exact. (this is the copyDir func I copied:…
AbrahamDN
  • 39
  • 3