@types/pupetteer
package and had problems.**TypeError: puppeteer.launch is not a function**
at Object.<anonymous> (/Users/dspiridonov/Documents/Programming/scrapper/dist/main.js:11:11)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
@Shoizz Please post more information than just a stack trace which is nowhere near enough to spot the issue. How does the code that calls puppeteer
look like?
@marvinhagemeister My bad, sorry.
tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"allowJs": true,
"outDir": "dist",
"strict": true,
"moduleResolution": "node",
"baseUrl": ".",
"esModuleInterop": true
}
}
main.ts
import * as puppeteer from 'puppeteer';
puppeteer.launch({headless:false})
.then((browser) =>
browser.newPage()
)
.then((page)=>
page.goto(url)
.then(()=>page.content())
).then((x)=>console.log(x))
package.json
"devDependencies": {
"@types/cheerio": "^0.22.10",
"@types/puppeteer": "^1.11.1",
"concurrently": "^4.1.0",
"typescript": "^3.2.2"
},
"dependencies": {
"cheerio": "^1.0.0-rc.2",
"firebase-admin": "^6.4.0",
"puppeteer": "^1.11.0"
}
With esModuleInterop
set to true, you should just use import puppeteer from 'puppeteer'
iirc.
@SimonSchick Thanks! Closing this one.
Most helpful comment
With
esModuleInterop
set to true, you should just useimport puppeteer from 'puppeteer'
iirc.