Fs.copyFile is not a Function

Asked

Viewed 1,430 times

1

I’m trying to manipulate files with Nodejs, using the fs.copyFile on my server (Debian Jessie), but I can’t copy files. I’ve done everything to try to solve the problem, already copied exactly the example given in the documentation and replicated the files, but it is always the same error that is returned (including using the fs.copyFileSync).

The error shown is the TypeError: fs.copyFile is not a function, and no additional information appears on it.

My code:

const fs = require('fs');

fs.copyFile('/home/savi/teste1.txt', '/home/savi/teste2.txt', (err) => {
    if(!err){
        console.log("Copiou");
    }
});
  • What is the return of console.log(fs)?

  • I just found out that, as I researched a generic term in Google to find the nodejs documentation regarding the copy of files, it returned me the documentation page of version V8.6 and not V6.11.3 that I’m using, and that’s definitely the mistake. The Fs.copyFile function only exists in V8.6 version. ;-;

1 answer

2


Functionality fs.copyFile added only in version 8.5 node.
It was very much expected as there was no simple API to copy files before.

Seeing in the documentation is there:

Added in: V8.5.0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.