EN
Node.js - copy file example
0 points
In this article, we would like to show you how to copy files in Node.js.
xxxxxxxxxx
1
const { copyFile } = require('fs/promises');
2
3
const copyFileAsync = async (sourcePath, destinationPath) =>{
4
try {
5
await copyFile(sourcePath, destinationPath);
6
console.log('copied successfully!');
7
} catch (error) {
8
console.log(error);
9
}
10
}
11
12
copyFileAsync('C:/path/to/file.txt', 'C:/path/to/file_copy.txt');
Result:


- More copy methods - Node.js - copy files