amoilanen / js-crawler

Web crawler for Node.JS
MIT License
253 stars 55 forks source link

Crawler is not a function #56

Open atomixstar opened 5 years ago

atomixstar commented 5 years ago

Hi, I am trying to setup a basic crawler script but I am getting an error:

new Crawler().configure({depth: 3}) ^ TypeError: Crawler is not a function at Object.<anonymous> (/var/www/user/test2.js:3:1) at Module._compile (module.js:410:26) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Function.Module.runMain (module.js:442:10) at startup (node.js:136:18) at node.js:966:3

test2.js

`var Crawler = require("js-crawler").default;

new Crawler().configure({depth: 3}) .crawl("http://www.google.com", function onSuccess(page) { console.log(page.url); });`

What I am doing wrong?

AnthoniG commented 5 years ago

Am getting the exact same thing. I am using Typescript as well, but still the same error message.

imkimchi commented 5 years ago

remove .default, you will be fine

raquelmsmith commented 2 years ago

I was getting TypeError: Crawler is not a constructor and removing .default worked for me 👍