js-crawler icon indicating copy to clipboard operation
js-crawler copied to clipboard

Crawler is not a function

Open atomixstar opened this issue 6 years ago • 3 comments

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?

atomixstar avatar Feb 14 '19 02:02 atomixstar

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

AnthoniG avatar Mar 05 '19 07:03 AnthoniG

remove .default, you will be fine

imkimchi avatar Mar 21 '19 11:03 imkimchi

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

raquelmsmith avatar Nov 16 '21 20:11 raquelmsmith