bzarras / newsapi

A promise-based node interface for NewsAPI
MIT License
144 stars 39 forks source link

Can't resolve 'core-js/modules/es6.array.index-of' #24

Closed seancgill closed 4 years ago

seancgill commented 4 years ago

1:17:24 AM react.1 | Failed to compile. 1:17:24 AM react.1 | ./node_modules/newsapi/dist/index.js 1:17:24 AM react.1 | Module not found: Can't resolve 'core-js/modules/es6.array.index-of' in 'C:\Users\abc\xyz-app\node_modules\newsapi\dist' 1:17:24 AM react.1 | Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys' 1:17:24 AM react.1 | Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys' 1:17:24 AM react.1 | Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys'

My file --->

import { NewsAPI } from 'newsapi'
const newsapi = new NewsAPI('api key string goes here');
//const NewsAPI = require('newsapi'); **Tried both commonJS and ES6 imports...same error**
function getNews(){
    newsapi.v2.everything({
    q: 'bitcoin',
    sources: 'bbc-news,the-verge',
    domains: 'bbc.co.uk, techcrunch.com',
    from: '2017-12-01',
    to: '2017-12-12',
    language: 'en',
    sortBy: 'relevancy',
    page: 2
  }).then(response => {
    console.log(response);
    /*
      {
        status: "ok",
        articles: [...]
      }
    */
  });
} 

I can't seem to figure this out...I feel incredibly dumb guys but I am so excited to use this library...if anyone could provide any sort of direction I would be so grateful!!! Thank you so much.

seancgill commented 4 years ago

Whoops...looks like I fixed it!>? Master googler here...fixed this by installing @corejs2 npm package.