Generated service cannot be injected until Ember serve is restarted
See original GitHub issueI got stuck for a little while trying to figure out why I couldn’t inject a newly created service. Turns out that restarting ember serve solved the issue, but still, here are the reduced steps to reproduce the problem every time:
ember new super-rentals
ember s
In another terminal:
ember g service shopping-cart
ember g component foo-cmp
application.hbs
{{foo-cmp}}
foo-cmp.js
import Component from '@ember/component';
import { inject as service } from '@ember/service';
export default Component.extend({
shoppingCart: service()
});
The full error message in the browser console:
“Error: Assertion Failed: Attempting to inject an unknown injection: ‘service:shoppingCart’ at new EmberError (http://localhost:4200/assets/vendor.js:24147:25) at assert (http://localhost:4200/assets/vendor.js:24390:15) at Registry.validateInjections (http://localhost:4200/assets/vendor.js:21434:66) at FactoryManager.create (http://localhost:4200/assets/vendor.js:21019:35) at Proxy.create (http://localhost:4200/assets/vendor.js:20802:20) at CurlyComponentManager.create (http://localhost:4200/assets/vendor.js:25615:37) at http://localhost:4200/assets/vendor.js:13213:33 at AppendOpcodes.evaluate (http://localhost:4200/assets/vendor.js:11612:13) at VM.next (http://localhost:4200/assets/vendor.js:18788:32) at TemplateIterator.next (http://localhost:4200/assets/vendor.js:18859:28)”
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:5 (4 by maintainers)

Top Related StackOverflow Question
Thank you ❤️
I was not able to reproduce using ember-cli v3.5, closing for now.