samedi 4 novembre 2017

Ember- "import Route from '@ember/routing/route';" throws error in Console

I'm following the Ember Quick Start guide (ember-cli v 2.11), and building the toy app along with the instructions. In the "Define A Route" section, the instructions say to run the command ember generate route scientists, which adds the route to router.js and creates a new scientists.js file in the routes folder. I notice that the auto-generated code in scientists.js includes with the following:

import Route from '@ember/routing/route';

export default Route.extend({
});

The instructions say that once I've filled out the corresponding scientists template with text, I should be able to navigate to localhost:4200/scientists and see (among other things) the text I added to the scientists template. However when I do so, the DOM is blank and the console contains an error:

Uncaught Error: Could not find module `@ember/routing/route` imported from `ember-quickstart/routes/foobar`
    at missingModule (loader.js:247)
    at findModule (loader.js:258)
    at Module.findDeps (loader.js:168)
    at findModule (loader.js:262)
    at requireModule (loader.js:24)
    at Class._extractDefaultExport (resolver.js:385)
    at Class.resolveOther (resolver.js:82)
    at Class.superWrapper [as resolveOther] (ember-utils.js:437)
    at Class.resolveRoute (resolver.js:304)
    at Class.resolve (resolver.js:141)

From previous work on Ember apps, I know that I could replace the default route contents with the following:

import Ember from 'ember';

export default Ember.Route.extend({
});

And in fact, this does work- I see what I expect to see, with no errors in the console.

My question is, why didn't the instructions produce the results I expected? I feel like I'm missing something elementary, but the Quick-Start page is pretty short and I don't see where I went wrong.

By the way, I've tried the same steps for generating components as well, which resulted in the same console error.




Aucun commentaire:

Enregistrer un commentaire