Definitelytyped: @types/puppeteer - Error when compiling

Created on 14 Aug 2018  路  9Comments  路  Source: DefinitelyTyped/DefinitelyTyped

Hi,
Im trying use puppeteer in an angular app and get this error when compiling.

ERROR in node_modules/@types/puppeteer/index.d.ts(15,38): error TS1005: ';' expected. node_modules/@types/puppeteer/index.d.ts(15,73): error TS1005: '(' expected. node_modules/@types/puppeteer/index.d.ts(15,76): error TS1005: ')' expected. node_modules/@types/puppeteer/index.d.ts(18,40): error TS1005: ';' expected. node_modules/@types/puppeteer/index.d.ts(18,68): error TS1005: ';' expected. node_modules/@types/puppeteer/index.d.ts(18,71): error TS1109: Expression expected.

and sometimes https://hastebin.com/upereteman.coffeescript .

@marvinhagemeister @cdeutsch @ksm2

Most helpful comment

@jsdevtom You need at least TypeScript 2.8 (see here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/puppeteer/index.d.ts#L7)
I tried your reproduction steps, using TypeScript 2.8 works:

  1. npm i [email protected]
  2. npm run build

All 9 comments

@iserifith Are you sure that your node_modules directory is up to date? The linked output looks like some dependencies are missing.

It was fresh angular instalation. I even tried remove the node modules folder and install it again. Here is my package.json

@iserifith The definitions are correct. Everything I can find on google with that error message points to using an outdated tsc instance. https://stackoverflow.com/questions/46398916/typescript-error-ts1005-expected?rq=1

I switch the typescript version to 2.8.1. however this still persist. Could it be a path issue? I manually check the node_module folders and everything is there.

@iserifith You are using puppeteer which is made for Node.js in a browser environment. Therefore, modules like fs, crypto and child_process are missing. This has nothing to do with these typings.

That makes sense. Thank you.

This still applies to node environments. Simple reproduction steps:

  1. Set up basic TypeScript environment: git clone --depth=1 https://github.com/Microsoft/TypeScript-Node-Starter.git <project_name>
  2. install dependencies: cd <project_name> && npm i -S puppeteer && npm i -S -D @types/puppeteer
  3. go to server.ts and import puppeteer: import puppeteer from 'puppeteer';
  4. try to compile npm run build

I have tried lots of combinations of ignoring node_modules to no avail. @ksm2 or anyone else: please advise how to solve this. @marvinhagemeister my TypeScript version is "typescript": "^2.7.2"

@jsdevtom You need at least TypeScript 2.8 (see here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/puppeteer/index.d.ts#L7)
I tried your reproduction steps, using TypeScript 2.8 works:

  1. npm i [email protected]
  2. npm run build

@ksm2 Thank you! That worked!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArtemZag picture ArtemZag  路  3Comments

alisabzevari picture alisabzevari  路  3Comments

JWT
svipas picture svipas  路  3Comments

lilling picture lilling  路  3Comments

variousauthors picture variousauthors  路  3Comments