This is the default option
import Seven from 'node-7z'; // or const Seven = require('node-7z');
const extract = Seven.extractFull('./archive.7z', './output/dir/', {
$progress: true
});
extract.on('data', function (data) {
doStuffWith(data)
});
extract.on('progress', function (progress) {
doStuffWith(progress)
});
extract.on('end', function () {
extract.info.get('Folders') //? '4'
});
extract.on('error', (err) => handleError(err));
You should have the a 7-Zip executable (v16.02 or greater) available in your system.
- On Debian and Ubuntu install the p7zip-full package or use 7-Zip 21.02 alpha or higher
- On Mac OSX use Homebrew brew install p7zip
- On Windows get 7-Zip from 7-Zip download page.
By default the module calls the 7z binary, it should be available in your PATH.
An alternative is to add the 7zip-bin module to your project. This module contains an up-to-date version of 7-Zip for all available plaforms. Then you can do:
import sevenBin from '7zip-bin'
import { extractFull } from 'node-7z'
const pathTo7zip = sevenBin.path7za
const seven = extractFull('./archive.7z', './output/dir/', {
$bin: pathTo7zip
});