How to use external JS in a service

Hello, I am trying to use Dexie in a service. I installed Dexie via npm, imported it into ember-cli via:


created a service file:

import Service from '@ember/service';
import Dexie from 'dexie';

    export default Service.extend({
        db: null,
        init() {
            this.db = new Dexie('MyDatabase');
            // Declare tables, IDs and indexes
                friends: '++id, name, age'
        addFriend() {
                name: 'Camilla',
                age: 25,

Chrome gives me this error:

Error: Could not find module dexie imported from ember-omnia-write/services/dexie

So my question is, how do I import this Library correctly or how can I refer to Dexie? Couldnt find any useful help on google.

Greetings :slight_smile:

EDIT 1: I kinda fixed it myself now by adding these arguments to ember-cli-build

app.import('node_modules/dexie/dist/dexie.min.js', {
  using: [
    { transformation: 'amd', as: 'Dexie' }
1 Like

Glad you got it figured out! You can also look at ember-auto-import for importing non-Ember js packages. It’s pretty neat and even allows lazy loading.