Skip to content
Advertisement

How can I move files to a directory using Node.JS?

like so

► add language identifier to highlight code

```python
def function(foo):
    print(foo)

► put returns between paragraphs

► for linebreak add 2 spaces at end

italic or bold

► indent code by 4 spaces

► backtick escapes like _so_

► quote by placing > at start of line

► to make links (use https whenever possible) https://example.com example example

Advertisement

Answer

var fs = require('fs-extra');
var request = require('request');
fs.ensureDir('css');
request('http://agar.io/css/master.css').pipe(fs.createWriteStream('master.css'));
fs.move('master.css', 'css/master.css', function (err) {
  if (err)
      console.error(err);
});
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement