question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot convert undefined or null to object

See original GitHub issue

When I write const browser = await puppeteer.launch(); it appears that puppeteer is undefined or null, because it returns the error in the title. I think this because after commenting out the rest of my code (in my async function) even when logging to the console it returns the error. Here is the config:

const puppeteer = require('puppeteer-extra');

const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());

Anyone know what’s happening?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
Camelcommented, Jun 23, 2020

Had the same issue and solved it by changing this line:

const browser = await puppeteer.launch()

To this:

const browser = await puppeteer.launch({})

As ref for the devs to see the source of the issue:

async launch(options) {
// Ensure there are certain properties (e.g. the `options.args` array)
  const defaultLaunchOptions = { args: [] };
  options = merge(defaultLaunchOptions, options);  // THIS LINE IS THE ISSUE
0reactions
ianfairbairncommented, Aug 7, 2020

I actually had to add a valid config setting to get this to work:

const browser = await puppeteer.launch( { defaultViewport: { width: 1020, height: 1020, deviceScaleFactor: 1 } } );

Using:

"puppeteer": "^5.2.1",
"puppeteer-extra": "^3.1.13",
"puppeteer-extra-plugin-angular": "^3.2.3",
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot convert undefined or null to object - Stack Overflow
Generic answer. This error is caused when you call a function that expects an Object as its argument, but pass undefined or null...
Read more >
Cannot convert undefined or null to object : r/learnjavascript
Your code throws the error because before fetch completes, location is undefined, but you are telling react to iterate over it, which can't...
Read more >
Cannot convert undefined or null to Object in JavaScript
The "Cannot convert undefined or null to Object" error occurs when we pass a null or an undefined value to a function that...
Read more >
Object.keys(null) possible - cannot convert undefined or null to ...
Conditions above this line allow msg===null to get into Object.keys(msg);. livedata_connection.js:1626 Uncaught TypeError: Cannot convert ...
Read more >
Error: "TypeError: Cannot convert undefined or nul...
Error: "TypeError: Cannot convert undefined or null to object" with Publish to Tableau Server tool. Article Options.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found