title: Angular 6 with lowdb - not getting it to work
body: <p>I'm trying to create an Electron app with Angular 6 that uses <a href="https://github.com/typicode/lowdb" rel="nofollow noreferrer">lowdb</a> as a local database.</p>
  
  <p>It's all very new to me and it's trial and error, but I don't seem to be able to figure out how to overcome the following error:</p>
  
  <p>I've installed lowdb in my application by using the commands</p>
  
  <p><code>npm install --save lowdb</code> <em>(edit: forgot to mention I did this already)</em></p>
  
  <p>and</p>
  
  <p><code>npm install --save @types/lowdb</code></p>
  
  <p>I've created a service to communicate with this "local database".</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import lowdb from 'lowdb';
  import { default as FileAsync } from 'lowdb/adapters/FileAsync';
  import { CurrentUserModel } from '../models/current-user';
  
  @Injectable({
    providedIn: 'root'
  })
  export class LowdbService {
  
    private db: lowdb.LowdbAsync;
  
    constructor() {
      this.initDatabase();
    }
  
    set( field: string, value: any ) {
      this.db.set( field, value ).write();
    }
  
    private async initDatabase() {
      const adapter = new FileAsync( 'db.json' );
      this.db = await lowdb( adapter );
  
      this.db.defaults( { user: CurrentUserModel } );
    }
  }
  </code></pre>
  
  <p>But when I include the service in the constructor of a component I get errors.</p>
  
  <pre><code>ERROR in ./src/app/services/lowdb.service.ts
  Module not found: Error: Can't resolve 'lowdb' in '/Users/paul/Projects/application-name/src/app/services'
  ERROR in ./src/app/services/lowdb.service.ts
  Module not found: Error: Can't resolve 'lowdb/adapters/FileAsync' in '/Users/paul/Projects/application-name/src/app/services'
  ℹ ｢wdm｣: Failed to compile.
  ERROR in src/app/services/lowdb.service.ts(2,12): error TS1192: Module '"/Users/paul/Projects/application-name/node_modules/@types/lowdb/index"' has no default export.
  src/app/services/lowdb.service.ts(3,14): error TS2305: Module '"/Users/paul/Projects/application-name/node_modules/@types/lowdb/adapters/FileAsync"' has no exported member 'default'.
  </code></pre>
  
  <p>As far as I can see I'm doing the same as mentioned in <a href="https://github.com/typicode/lowdb/issues/233#issuecomment-434501199" rel="nofollow noreferrer">this Github comment</a> and <a href="https://stackoverflow.com/questions/52063654/how-to-create-lowdb-in-typescriptmain-ts-angular">this Stackoverflow comment</a>. I can't find any more documentation though.</p>
  
  <p>Can somebody help me out?</p>
  
  <p><em>Update</em><br>
  Using <code>import * as lowdb from 'lowdb'</code> seemed to solve my initial errors. But it resulted in a few other errors. See below.</p>
  
  <pre><code>ERROR in ./node_modules/graceful-fs/polyfills.js
  Module not found: Error: Can't resolve 'constants' in '/Users/paul/Projects/project-name/node_modules/graceful-fs'
  ERROR in ./node_modules/graceful-fs/graceful-fs.js
  Module not found: Error: Can't resolve 'fs' in '/Users/paul/Projects/project-name/node_modules/graceful-fs'
  ERROR in ./node_modules/graceful-fs/fs.js
  Module not found: Error: Can't resolve 'fs' in '/Users/paul/Projects/project-name/node_modules/graceful-fs'
  ERROR in ./node_modules/graceful-fs/legacy-streams.js
  Module not found: Error: Can't resolve 'stream' in '/Users/paul/Projects/project-name/node_modules/graceful-fs'
  </code></pre>