question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated service cannot be injected until Ember serve is restarted

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
IvaWonderbushcommented, Feb 8, 2018

Thank you ❤️

0reactions
pixelhandlercommented, Oct 26, 2018

I was not able to reproduce using ember-cli v3.5, closing for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overview - Services - Ember Guides
Injected properties are lazy loaded; meaning the service will not be instantiated until the property is explicitly called.
Read more >
Can't use old {inject as service} from ... with ember-decorators
I've been chasing down a plethora of Assertion Failed: InjectedProperties should be defined with the inject computed property macros. errors.
Read more >
ember serve and browser reload results in "cannot GET /foo ...
Ember built-in server looks at the environment.js locationType property to figure out if it must serve routes after the rootURL path.
Read more >
Shoebox - Ember FastBoot
FastBoot brings server-side rendering to Ember.js applications. ... FastBoot registers the fastboot service which you can inject into your application:
Read more >
Step 2: Create a new Ember app using Ember CLI
We're going to generate a new Ember application from scratch using the Ember CLI. In your shell, navigate to the directory on your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found