Ty Kayn
Ty Kayn

Reputation: 809

Ember : Could not find module `@ember-intl/intl-relativeformat` imported from `ember-intl/services/intl`

I added the module ember-intl in my app since the ember-i18n is deprecated. so yarn works well, updates package.json and yarn.lock (i got rid of the package.lock), but i get this error on the browser's console after a successful ember build:

Error: Could not find module @ember-intl/intl-relativeformat imported from ember-intl/services/intl

But in my node_modules the folders @ember-intl/intl-relativeformat and ember-intl both exist. in the yarn.lock i have this line: "@ember-intl/intl-relativeformat@^2.1.0":

more info:

Ember : 3.5.1
Ember Data : 3.5.0
jQuery : 3.3.1 Ember Remodal : 2.18.0

Upvotes: 4

Views: 1317

Answers (2)

Felipe Zavan
Felipe Zavan

Reputation: 1813

I solved this problem by adding ember-auto-import to my project. It comes pre-installed in new Ember projects, but needs to be added manually to older ones.

Just run ember install ember-auto-import and that's it.

Upvotes: 1

sheriffderek
sheriffderek

Reputation: 9043

I just installed it to see if a blank slate would show me that error.

It did not. : /

I just had a few beers... but I just want to make sure you imported the service.

the docs show:

// app/routes/application.js
export default Route.extend({
  intl: service(),
  beforeModel() {
    return this.intl.setLocale(['fr-fr', 'en-us']); /* array optional */
  }
});

but like most docs - assume you know the larger ecosystem. It's a tiny possibility that you might not have imported the module above import Service from '@ember/service'; etc.? https://guides.emberjs.com/release/applications/services/

if not that... then track down the mentioned 'ember-intl/services/intl' and see if you can figure out why the '@ember-intl/intl-relativeformat' import isn't jiving. Maybe check the repo and the version - and ask there on GitHub?

Good luck!

Upvotes: 0

Related Questions