[Bug]: SyntaxError: The requested module 'puppeteer' does not provide an export named 'ElementHandle'
See original GitHub issueBug description
Steps to reproduce the problem:
- source code
app.ts
import { ElementHandle, Page } from 'puppeteer';
class CustomElement {
print(): void {
console.log(`${Page.name} ${ElementHandle.name}`);
}
}
const elem = new CustomElement();
elem.print();
package.json
{
"module": "./app.js",
"types": "./app.d.ts",
"type": "module",
"dependencies": {
"puppeteer": "^16.2.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
}
}
tsconfig.json
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"moduleResolution": "node",
"module": "ESNext",
"target": "ESNext",
"lib": [
"ESNext",
"DOM",
],
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
},
"exclude": [ "node_modules" ],
}
- run the program
$(npm bin)/ts-node --esm app.ts
ornode --loader ts-node/esm app.ts
Puppeteer version
16.2.0
Node.js version
16.8.0
npm version
7.14.0
What operating system are you seeing the problem on?
macOS
Relevant log output
user@MacBook-Pro app % $(npm bin)/ts-node --esm app.ts
file://app.ts:1
import { ElementHandle, Page } from 'puppeteer';
^^^^^^^^^^^^^
SyntaxError: The requested module 'puppeteer' does not provide an export named 'ElementHandle'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:179:5)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
at async handleMainPromise (node:internal/modules/run_main:63:12)
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top Results From Across the Web
"The requested module ' does not provide an export named ...
You've confirmed that the package.json in the module's folder doesn't have "type": "module" in it. That's the issue. It's using the older ...
Read more >the requested module 'node-fetch' does not provide an export ...
node-postgres pg library that you are trying to import is transpiled. This means that you can't use named imports the way you are...
Read more >node_modules/puppeteer/lib/types.d.ts - devtools ... - Google Git
A Browser is created when Puppeteer connects to a Chromium instance, either through ... JavaScript Coverage doesn't include anonymous scripts by default.
Read more >export/import on Node.js is driving me crazy. - Reddit
But I keep getting this error: ... polygonCovalentConfig.js' does not provide an export named ... SyntaxError: The requested module '.
Read more >Puppeteer documentation - DevDocs
Puppeteer Documentation. Overview. Puppeteer is a Node library which provides a high-level API to control Chromium or Chrome over the DevTools Protocol. The ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t think we export those classes. We only export types for them. You can implement duck-typing currently but not the instanceof checks, e.g.,
Similarly,
leads to
SyntaxError: The requested module 'puppeteer' does not provide an export named 'ElementHandle'
andSyntaxError: The requested module 'puppeteer' does not provide an export named 'Page'
which may only be surppressed by either
or
but will end up with a new error: