0

I created services/store.js with default export, then I added "@service store;" in route. Right at that line the following error occurs:

TypeError: Cannot read properties of undefined (reading 'default')
    at Module.default (webpack://tkl/./services/store.js?:3:107)
    at Resolver._extractDefaultExport (webpack://tkl/../rewritten-packages/ember-resolver.4afe6404/node_modules/ember-resolver/index.js?:389:25)
    at Resolver.resolveOther (webpack://tkl/../rewritten-packages/ember-resolver.4afe6404/node_modules/ember-resolver/index.js?:150:32)
    at Resolver.resolve (webpack://tkl/../rewritten-packages/ember-resolver.4afe6404/node_modules/ember-resolver/index.js?:171:23)
    at resolve (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:725:1)
    at Registry.resolve (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:506:1)
    at Registry.resolve (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:508:1)
    at has (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:738:1)
    at Registry.has (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:588:1)
    at Registry.proto.validateInjections (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:710:1)
    at InternalFactoryManager.create (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:369:1)
    at Proxy.create (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:204:1)
    at instantiateFactory (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:276:1)
    at lookup (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:223:1)
    at Container.lookup (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:121:1)
    at ApplicationInstance.lookup (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/runtime/lib/mixins/container_proxy.js:19:1)
    at PrivateRouter.getRoute (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/routing/router.js:183:1)
    at UnresolvedRouteInfoByParam.fetchRoute (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:714:1)
    at UnresolvedRouteInfoByParam.get route [as route] (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:648:1)
    at URLTransitionIntent.applyToState (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1151:1)
    at PrivateRouter.getTransitionByIntent (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1276:1)
    at PrivateRouter.transitionByIntent (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1239:1)
    at PrivateRouter.doTransition (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1357:1)
    at PrivateRouter.handleURL (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1748:1)
    at Router._doURLTransition (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/routing/router.js:474:1)
    at Router.handleURL (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/routing/router.js:470:1)
    at ApplicationInstance.visit (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/application/instance.js:215:1)
    at EmberApp._visit (/Users/boris/Projects/tkl/node_modules/fastboot/src/ember-app.js:269:20)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at EmberApp.visit (/Users/boris/Projects/tkl/node_modules/fastboot/src/ember-app.js:329:7)
    at FastBoot.visit (/Users/boris/Projects/tkl/node_modules/fastboot/src/index.js:86:18)
    at /Users/boris/Projects/tkl/node_modules/fastboot-express-middleware/src/index.js:33:20

I tried to inject store using getter or somehow debug/google the problem. However, it leads to nowhere. Has someone any ideas about that?

Here's the code that generates the error:

Route:

// app/routes/blogposts.ts
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
    
export default class BlogpostsRoute extends Route {
  @service store;
    
  // no matter what is inside this hook and whether it exists at all, no impact on the error
  model(params) {
  }
}

Adapter:

// app/adapters/blogpost.ts
import RESTAdapter from '@ember-data/adapter/rest';
        
export default class BlogpostAdapter extends RESTAdapter {
  host = 'http://localhost:3333';
}
        
declare module 'ember-data/types/registries/adapter' {
  export default interface AdapterRegistry {
    blogpost: BlogpostAdapter;
  }
}

Serializer:

// app/serializers/blogpost.ts
import RESTSerializer from '@ember-data/serializer/rest';
    
export default class BlogpostSerializer extends RESTSerializer {}
    
declare module 'ember-data/types/registries/serializer' {
  export default interface SerializerRegistry {
    blogpost: BlogpostSerializer;
  }
}

Service:

// app/services/service.js
export { default } from 'ember-data/store';
3
  • Please share with us a code snap with a focus on the problem!! Commented Mar 24, 2024 at 16:00
  • hello! thanks for asking! can you add some formatting to your post, and perhaps the code that caused the error? thanks!!! Commented Mar 24, 2024 at 16:00
  • @NullVoxPopuli Yep, sorry for the format. I fixed it and added code snippets to the original post. Thank you! Commented Mar 24, 2024 at 16:25

2 Answers 2

0

I see

// app/services/service.js
export { default } from 'ember-data/store';

try renaming this file to

// app/services/store.js
import Store from 'ember-data/store';

export default Store;
Sign up to request clarification or add additional context in comments.

4 Comments

No, sorry, that's a typo. That comment isn't copied, it was written by me. File name is store.js actually. But it doesn't matter. Even if I delete this store.js at all, I still have the same.
what happens if you re-add the file and do import Store from 'ember-data/store' and then export default Store;?
If I try it like you advise, I get another error: ReferenceError: Cannot access 'WEBPACK_DEFAULT_EXPORT' before initialization at Module.default (webpack://tkl/./services/store.js?:3:42) .......
The issue disappears once I disable Fastboot.
0

The problem is solved. The solution is Fastboot incompatible with modern state of the ecosystem

I applied changes from branch "fastboot-broken" which is not merged at this moment of writing this post. Once I did, the problem disappeared.

2 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
It is actually NullVoxPopuli's branch "fastboot-broken" that is the answer. The problem was solved one I applied his changes from that branch which is not merged yet. I will mention this in my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.