Search code examples
javascriptnode.jsfilesystemsfs

Node JS File system


I'm learning node.js and currently on how to copy file system,

import * as fs from 'fs';
import * as fs from 'fs/promises';
fs.copyFileSync("file1.txt", "file2.txt");

Using the above in VS code, I get prompts like: remove import from fs for first and second line, the fs in the third line is red, please help


Solution

  • You are importing two module as one variable

    You can try import fs from "fs" and remove the second line, and your code fs.copyFileSync() is correct