Travis-CI Cannot find some default node modules

Travis CI build fails to find some default node modules such as File System (fs) or Buffer in both Ionic and Electron apps.

Error:

ERROR in node_modules/typeorm/platform/PlatformTools.d.ts(2,28): error TS2307: Cannot find module 'fs'.
ERROR in node_modules/typeorm/driver/cockroachdb/CockroachConnectionCredentialsOptions.d.ts(2,28): error TS2307: Cannot find module 'tls'
node_modules/typeorm/platform/PlatformTools.d.ts(4,36): error TS2307: Cannot find module 'stream'.
node_modules/typeorm/platform/PlatformTools.d.ts(38,44): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`

.travis.yml:

language: node_js
node_js: "8"

branches:
  only: 
    - master

before_install:
  - npm i npm@^6 -g

install:
  - npm install
  - npm i @types/node

before_script:
  - npm install -g ionic cordova
  - npm install -g @angular/cli

script:
  - ionic cordova build browser - prod
  - ng build --prod --aot

    language: node_js
node_js: "8"

branches:
  only: 
    - master

before_install:
  - npm i npm@^6 -g

install:
  - npm install
  - npm i @types/node

before_script:
  - npm install -g ionic cordova
  - npm install -g @angular/cli

script:
  - ionic cordova build browser - prod
  - ng build --prod --aot