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.

'"puppeteer"' has no exported member 'puppeteer' using Typescript

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 8.0.0 / 7.1.0
  • Platform / OS version: Windows 10
  • URLs (if applicable):
  • Node.js version: 14.16.0

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Install puppeteer and @types/puppeteer 5.4.3
  2. Create a .ts file with the following code
import { puppeteer } from "puppeteer";

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://news.ycombinator.com', {
    waitUntil: 'networkidle2',
  });
  // page.pdf() is currently supported only in headless mode.
  // @see https://bugs.chromium.org/p/chromium/issues/detail?id=753118
  await page.pdf({
    path: 'hn.pdf',
    format: 'letter',
  });

  await browser.close();
})();
  1. Get the error Module '"puppeteer"' has no exported member 'puppeteer'.ts(2305) at the first line

What is the expected result?

What happens instead?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

5reactions
nik-k999commented, May 12, 2021

Try to add following in your tsconfig.json:

"compilerOptions": {
  "allowSyntheticDefaultImports": true,
},
1reaction
nik-k999commented, May 13, 2021

If you open the following file “node_modules/@types/puppeteer/index.d.ts”, you will notice there is no default export. Instead each class, interface, etc. are exported just with the “export” statement. So if you want to import something from puppeteer and you are using ES6 Modules, you have to use curly braces. e.g.:

import { launch } from "puppeteer"

More Infos

However, Typescript offers the feature “allowSyntheticDefaultImports”. Basically it allows to import everything as default if there is no default export in the file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] TypeScript issues with puppeteer v7 ("no exported ...
Solution: Use puppeteer@5 for now. Longer answer: It's painful to see that puppeteer broke perfectly fine typings through @types/puppeteer . Due ...
Read more >
Puppeteer types node_modules/puppeteer/lib/types"' has no ...
So, say if I ran into a ... has no exported member HttpMethod error, I would create a typings file, (e.g. httpMethod.type.ts )...
Read more >
node_modules/puppeteer/lib/types.d.ts - devtools ... - Google Git
A Browser is created when Puppeteer connects to a Chromium instance, ... **NOTE** BrowserFetcher is not designed to work concurrently with other.
Read more >
angular/core/core"' has no exported member ... - appsloveworld
The way I check that in my projects is to look for angular different than 10 in your package-lock.json file to find what...
Read more >
puppeteer-extra - npm
puppeteer -extra is a drop-in replacement for puppeteer, // it augments the installed puppeteer with plugin functionality.
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