N0taN3rd / node-warc

Parse And Create Web ARChive (WARC) files with node.js
MIT License
92 stars 20 forks source link

AutoWARCParser is not a constructor #32

Closed Austinb closed 4 years ago

Austinb commented 4 years ago

Trying to use AutoWARCParser but when using the example from the readme.md

const {AutoWARCParser} = require('node-warc');

const parser = new AutoWARCParser('/path/to/my.warc.gz');
parser.on('record', record => { console.log(record); });
parser.on('done', () => { console.log('finished'); });
parser.on('error', error => { console.error(error); });
parser.start();

I get the following error when running the test_warc.js file:

/home/test_warc.js:4
const parser = new AutoWARCParser(
               ^

TypeError: AutoWARCParser is not a constructor
    at Object.<anonymous> (/home/test_warc.js:4:16)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
# node -v
v10.16.0

# npm -v
6.10.1

# lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic
BubuAnabelas commented 4 years ago

That's weird, I've just tested it and it works without any problems. Try reinstalling the package.

Austinb commented 4 years ago

Turns out my project was using version 2.x of the project. I did not realize it was up to 3.x since there are no tagged releases in github. Works as expected in 3.x.