How to untar file in node.js

There are some untar libraries, but I cannot get them working.

My idea would be something like

untar(bufferStreamOrFilePath).extractToDirectory("/path", function(err){})

Is something like this available?

The tar-stream module is a pretty good one:

var tar = require('tar-stream')    

var extract = tar.extract();
extract.on('entry', function(header, stream, callback) {
    // make directories or files depending on the header here...
    // call callback() when you're done with this entry
});

fs.createReadStream("something.tar").pipe(extract)

extract.on('finish', function() {
    console.log('done!')
});

Just an update on this answer, instead of node-tar, consider using tar-fs which yields a significant performance boost, as well as a neater interface.

var tarFile = 'my-other-tarball.tar';
var target = './my-other-directory';

// extracting a directory
fs.createReadStream(tarFile).pipe(tar.extract(target));