Ember Beginner - Managing Dependencies

Hi there its me again :),

i am completly new to ember and i am stuck again and need your help. i am developing a addon in ember. For my addon frontend i wanted to implement a specific bootstrap library. (sb admin 2)

i added the dependencie with npm: npm i startbootstrap-sb-admin-2

after i tried to import the css and js in my entry point index.js app.import(‘node_modules/startbootstrap-sb-admin-2/css/sb-admin-2.css’); app.import(‘node_modules/startbootstrap-sb-admin-2/js/sb-admin-2.js’);

But if i try to start my application now (ember s), then i get the following message.

$ ember s
Unexpected identifier


Stack Trace and Error Report: C:\Users\flori\AppData\Local\Temp/error.dump.6bb455335c4a149657652a7333111b54.log

here my index.js file:

'use strict';

module.exports = {
  name: require('./package').name

  app.import('node_modules/startbootstrap-sb-admin-2/css/sb-admin-2.css');
  app.import('node_modules/startbootstrap-sb-admin-2/js/sb-admin-2.js');

};

Someone know what I am doing wrong ?

Yes, you have syntax errors in index.js (meaning Node can’t figure out how to parse it as valid Javascript).

Try something like this:

'use strict';

module.exports = {
  name: require('./package').name,
  included() {
    this._super.included.apply(this, arguments);
    this.import('node_modules/startbootstrap-sb-admin-2/css/sb-admin-2.css');
    this.import('node_modules/startbootstrap-sb-admin-2/js/sb-admin-2.js');
  }
};
1 Like

ty for your help. yeah i noticed some syntax errors after creating that post. like the “,” after name. i had in my current state the include function too. your code works btw, ty ! my current old one looked almost the same. idk what i did wrong in that one. but now it works anyway. ty !