Search code examples
ember.jsember-cli

Ember-cli: Expected an assignment or function call


I'm getting the following error every time I ember server on my ember-cli project:

router.js: line 12, col 45, Expected an assignment or function call and instead saw an expression
router.js: line 16, col 48, Expected an assignment or function call and instead saw an expression
router.js: line 20, col 41, Expected an assignment or function call and instead saw an expression
router.js: line 23, col 25, Expected an assignment or function call and instead saw an expression

I've gone over and over my router.js file and can't seem to find the issue:

import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
  location: config.locationType
});

Router.map(function() {
    this.resource('dashboard',{path:'/'}),
    this.resource('items',{path:'/items'},function(){
        this.route('new'),
        this.route('edit',{path:'/:item_id'});
    }),
    this.resource('abilities',function() {
        this.route('new'),
        this.route('edit',{path:'/:ability_id'});
    }),
    this.resource('ships',function(){
       this.route('new'),
       this.route('edit',{path:'/:slug'});
    });
});

export default Router;

I thought that the dynamic segments on the routes might be the issues, but the error still came up even after changing them to resources. I did have ; at the end of each line instead of commas so I tried switching it, but that didn't fix it either. Any suggestions as to what I'm doing wrong would be appreciated. Thanks!


Solution

  • You do need semi-colons after your this.resource and this.route entries, not commas. This might not actually affect the program behavior, but it will make js[lh]int unhappy. What error was reported when you used semi-colons?