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

Cannot read property 'startsWith' of undefined #94

Closed
fakhir-shad opened this issue Jun 26, 2020 · 4 comments
Closed

Cannot read property 'startsWith' of undefined #94

fakhir-shad opened this issue Jun 26, 2020 · 4 comments

Comments

@fakhir-shad
Copy link

fakhir-shad commented Jun 26, 2020

Having trouble using openGraphScraper, even with the default example i am getting error, i have tried different versions from 4.00 to 4.2.0 but received the same error. I have also tried removing the node_modules and package-lock.json. I am using node 10.16.3
Using this example

const ogs = require('open-graph-scraper');
const options = { url: 'https://www.npmjs.com/package/open-graph-scraper' };
ogs(options)
  .then((data) => {
    const { error, result, response } = data;
    console.log('error:', error);  // This is returns true or false. True if there was a error. The error it self is inside the results object.
    console.log('result:', result); // This contains all of the Open Graph results
    console.log('response:', response); // This contains the HTML of page
  })

I am getting this error

   { error: true
    result: {
      "success": false,
      "requestUrl": "https://www.npmjs.com/package/open-graph-scraper",
      "error": "Cannot read property 'startsWith' of undefined",
      "errorDetails": {
        "name": "RequestError"
      }
    }}

Screenshot from 2020-06-26 16-44-54

@jshemas
Copy link
Owner

jshemas commented Jun 26, 2020

Using your code example I am unable to reproduce the problem. I'm using Node v10.16.3 and here are my resultes:

{ ogDescription:
   'Node.js scraper module for Open Graph and Twitter Card info',
  ogTitle: 'open-graph-scraper',
  ogUrl: 'https://www.npmjs.com/package/open-graph-scraper',
  ogSiteName: 'npm',
  twitterCard: 'summary',
  twitterUrl: 'https://www.npmjs.com/package/open-graph-scraper',
  twitterTitle: 'npm: open-graph-scraper',
  twitterDescription:
   'Node.js scraper module for Open Graph and Twitter Card info',
  ogImage:
   { url:
      'https://static.npmjs.com/338e4905a2684ca96e08c7780fc68412.png',
     width: null,
     height: null,
     type: 'png' },
  ogDate: '2020-06-23T23:52:25.488Z',
  requestUrl: 'https://www.npmjs.com/package/open-graph-scraper',
  success: true }

What operating system are you running this on? Do you see this with other websites?

Can you try running this with open-graph-scraper@4.2.1 ? I added a extra check here fe499dd but I don't think that is the issue.

@jshemas
Copy link
Owner

jshemas commented Jun 28, 2020

I got this error when messing with https://www.npmjs.com/package/proxy-agent, is your app using a proxy agent?

result: { success: false,
  requestUrl: 'https://www.npmjs.com/package/open-graph-scraper',
  error: 'Cannot read property \'startsWith\' of undefined',
  errorDetails:
   { RequestError: Cannot read property 'startsWith' of undefined
       at PromisableRequest._makeRequest (C:\openGraphScraper\node_modules\got\dist\source\core\index.js:1010:19)
       at Request (C:\openGraphScraper\node_modules\got\dist\source\core\index.js:270:28)
       at urlToOptions (internal/url.js:1259:28)
       at Object.request (https.js:279:15)
       at Object.<anonymous> (C:\openGraphScraper\node_modules\agent-base\patch-core.js:25:22)
       at C:\openGraphScraper\node_modules\socks-proxy-agent\node_modules\agent-base\patch-core.js:23:20
       at PromisableRequest._makeRequest (C:\openGraphScraper\node_modules\got\dist\source\core\index.js:982:43)
       at Request (C:\openGraphScraper\node_modules\got\dist\source\core\index.js:270:28)
       at process._tickCallback (internal/process/next_tick.js:68:7) name: 'RequestError', code: undefined, timings: undefined } }

@jshemas
Copy link
Owner

jshemas commented Jul 15, 2020

This might also be a issue with got, it only supports node 10.19.0 and up.

https://github.com/sindresorhus/got/blob/master/package.json#L10

@jshemas
Copy link
Owner

jshemas commented Jun 10, 2021

Closing due to inactivity and node10 has reached it's end of life.

@jshemas jshemas closed this as completed Jun 10, 2021
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

2 participants