Giter Club home page Giter Club logo

Comments (5)

F3n67u avatar F3n67u commented on June 27, 2024 1

yes. it's not an doc-only issue.

If it's not an doc-only issue, could you please clarify what exactly the issue is?

from node.

RedYetiDev avatar RedYetiDev commented on June 27, 2024
import { copyFile, constants } from 'node:fs';

function callback(err) {
  if (err) throw err;
  console.log('source.txt was copied to destination.txt');
}

// destination.txt will be created or overwritten by default.
copyFile('source.txt', 'destination.txt', callback);

// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback); 

The documentation mentions an err argument in the callback demo code, but no where else in the docs, CC @nodejs/fs

from node.

F3n67u avatar F3n67u commented on June 27, 2024

From my test, fs.copyFile's callback has a err param.

$ node test.mjs 
file:///test.mjs:4
  if (err) throw err;
           ^

[Error: ENOENT: no such file or directory, copyfile 'source.txt' -> 'destination.txt'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'copyfile',
  path: 'source.txt',
  dest: 'destination.txt'
}

Node.js v22.2.0


$ cat test.mjs                                                                
import { copyFile } from 'node:fs';

function callback(err) {
  if (err) throw err;
  console.log('source.txt was copied to destination.txt');
}

// destination.txt will be created or overwritten by default.
copyFile('source.txt', 'destination.txt', callback);

from node.

RedYetiDev avatar RedYetiDev commented on June 27, 2024

I ran the same code and got the same result, this seems like a doc-only issue. @Vikranthraosb is that was you were referring to?

from node.

Vikranthraosb avatar Vikranthraosb commented on June 27, 2024

yes. it's not an doc-only issue.

from node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.