简体   繁体   中英

How do I get my ember.js app to import modules installed from bower or npm

I'm pretty new to some of this stuff and I feel like I must just be missing something simple. I have a very basic Ember.js app that I created with the CLI tool flowing the guide. The code is at https://github.com/nfriedly/particle-webhook-manager

It has a couple of routes and components, and a single third-party dependency, particle-api-js. I installed it twice, via bower and npm, and I'm importing it in one of my components like so :

import particle from 'particle-api-js';

I start up my server with ember serve and it builds successfully. I then open my browser to http://localhost:4200/login where I load the component and it gives me the following error in my console:

Error: Could not find module `particle-api-js` imported from `particle-webhook-manager/components/login-form`

So, my main question is: what am I doing wrong here/how do I make it work?

My secondary question is: why did it "build" successfully and then throw a runtime error for the missing module - shouldn't it have found that in the build stage?

You should not use bower anymore. Use ember browserify to import things installed with npm .

You can import bower modules in your ember-cli-build.js with app.import('bower_components/...js') .

You can not import them directly, but you can create a vendor shim to provide this for you. Checkout the ember-cli documentation for this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM