Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i try to use but i have error #62

Open
pingplass123 opened this issue Nov 1, 2024 · 8 comments
Open

i try to use but i have error #62

pingplass123 opened this issue Nov 1, 2024 · 8 comments

Comments

@pingplass123
Copy link

pingplass123 commented Nov 1, 2024

TypeError: (0 , google_news_scraper_1.default) is not a function

and this is my code

      import googleNewsScraper from 'google-news-scraper';

      const articles = await googleNewsScraper({ searchTerm: "The Oscars" }); 
      return articles;

by the i use nestjs typescript

@pingplass123
Copy link
Author

any solution for this issue? @lewisdonovan

@lewisdonovan
Copy link
Owner

I can't replicate your issue. I've created a minimum example in this repo: https://github.com/lewisdonovan/gns-example
If you pull this repo and run it locally (see the instructions in the README file) does it work for you?

If so, there's likely something wrong with your setup. Providing a minimum example of your non-working code will help me to identify the issue for you.

If the minimum example I've provided doesn't work, then it's likely an incompatibility with your environment. If you can share details of what system/server environment you're running this on, I can help you to find the issue.

@pingplass123
Copy link
Author

this repo: https://github.com/lewisdonovan/gns-example is working but my project is using nestjs so i use this for api getting news and then response back

@lewisdonovan
Copy link
Owner

lewisdonovan commented Nov 1, 2024

Ok, great that we've narrowed that down. So now if you can provide a minimum reproducible example?

Providing a minimum example of your non-working code will help me to identify the issue for you.

☝️

@flitzcore
Copy link

Hi, I wonder if you have solved this yet. I use nest js and stumble into the same problem. For me it's because how NestJs or Ts look for type. Converting:
import googleNewsScraper from 'google-news-scraper';

into

const googleNewsScraper = require('google-news-scraper');

solved the issue for me

@utlandingur
Copy link

I'm also using nextjs and also have the same error

Could not find a declaration file for module 'google-news-scraper'. '/Users/lukehening/Sites/podcast-episode-recommender/node_modules/google-news-scraper/dist/esm/index.mjs' implicitly has an 'any' type.
  There are types at '/Users/lukehening/Sites/podcast-episode-recommender/node_modules/google-news-scraper/dist/tsc/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'google-news-scraper' library may need to update its package.json or typings.ts(7016)

I'm seeing if I can get around it (in a bad way) by creating my own type in global.d.ts

@BaptisteLecat
Copy link

Hi, I wonder if you have solved this yet. I use nest js and stumble into the same problem. For me it's because how NestJs or Ts look for type. Converting: import googleNewsScraper from 'google-news-scraper';

into

const googleNewsScraper = require('google-news-scraper');

solved the issue for me

Having the same issue with NestJS and this work for me

@utlandingur
Copy link

utlandingur commented Jan 3, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants