Copy a source file to another destination in Nodejs
<p>I'm trying to copy an image from a folder to another using fs-extra module .</p>

<pre><code>var fse = require('fs-extra');

function copyimage() {
  fse.copy('mainisp.jpg', './test', function (err) {     
    if (err) 
      return console.error(err)
  });
}
</code></pre>

<p>This is my directory
<img src="https://i.stack.imgur.com/Yi8qw.png" alt=""></p>

<p>and this is the error I get all the time:</p>

<blockquote>
  <p>Error {errno: -4058, code: "ENOENT", syscall: "lstat", path:
  "E:\mainisp.jpg", message: "ENOENT: no such file or directory, lstat
  'E:\mainisp.jpg'"}</p>
</blockquote>

<p><img src="https://i.stack.imgur.com/JkgRU.png" alt=""></p>

<p>and by changing destination to <code>./test/</code> I get this error</p>

<blockquote>
  <p>Error {errno: -4058, code: "ENOENT", syscall: "lstat", path:
  "E:\Development\Node apps\Node softwares\Digital_library\mainisp.jpg",
  message: "ENOENT: no such file or directory, lstat 'E:\Devel…
  apps\Node softwares\Digital_library\mainisp.jpg'"}</p>
</blockquote>

<p>Note: I'm not testing this in browser. It's an Nwjs app and the pics of error attached are from Nwjs console.</p>