Search code examples
ember.jsember-cliember-cli-mirage

Ember.js 'faker' is not defined


I'm trying to start a server from a repo but having issues getting it started because of the following error:

ember serve


Livereload server on http://localhost:49152
Serving on http://localhost:4200/

mirage/factories/page.js: line 4, col 42, 'faker' is not defined.

1 error

mirage/scenarios/default.js: line 7, col 19, 'domain' is defined but never used.
mirage/scenarios/default.js: line 13, col 105, Missing semicolon.
mirage/scenarios/default.js: line 5, col 7, 'ads' is defined but never used.

3 errors

===== 2 JSHint Errors

page.js:

import { Factory } from 'ember-cli-mirage';

export default Factory.extend({
    permalink: function() { return '/' + faker.lorem.words(1); }
});

What is wrong here? I also manually installed faker using npm but it doesn't seem to have any effect at all and I'm still stuck with this error.


Solution

  • faker should be included in the ember-cli-mirage namespace, so just import it along with Factory:

    import { Factory, faker } from 'ember-cli-mirage';