3

I have a nodejs application using "watson-developer-cloud" module. Included this module using "npm install --save watson-developer-cloud".

I see the issue below when running "npm run tsc".

node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts(4,35): error TS2304: Cannot find name 'File'.
node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts(4,42): error TS2304: Cannot find name 'ReadableStream'.

I am running this on Mac. node version 10.15.3. I found few articles asking to set path to node bin directory and reload terminal. I did that - although running into the same problem again.

node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts(4,35): error TS2304: Cannot find name 'File'.
node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts(4,42): error TS2304: Cannot find name 'ReadableStream'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! my-program@1.0.0 tsc: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the my-program@1.0.0 tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-03-25T14_29_06_333Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! my-program@1.0.0 build: `npm run tsc && npm run tslint`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the my-program@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-03-25T14_29_06_351Z-debug.log
ERROR: Service 'my-program' failed to build: The command '/bin/sh -c npm run build' returned a non-zero code: 2```
alexpls
  • 1,914
  • 20
  • 29
user11254486
  • 51
  • 1
  • 3

1 Answers1

13

The File and ReadableStream types are defined in the dom TypeScript library.

Try adding it to your tsconfig.json:

{
  ...
  "compilerOptions": {
    "lib": [
      ...
      "dom"
    ]
  }
}
alexpls
  • 1,914
  • 20
  • 29