Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the error "Unable find module with ID" with Aurelia Router

I'm trying to configure routes in Aurelia using aurelia-router, but it throws an error that it can't find the moduleId(route to file) of my route.

I configure my routes in two files router.js and app.js, router file only contains an array with all the routes. app file is the main file of my project.

Project Structure:

Project structure

Router.js:

export default [
  { route: ['', '/', 'home'], name: 'home', title: 'Inicio', layoutView: 'components/common/layout/layout.html', moduleId: 'components/home/home' }
]

App.js

import routes from 'router'
import {RouterConfiguration, Router} from 'aurelia-router';

export class App {

  configureRouter(config, router){
    config.options.root = '/';
    config.title = 'La Tatuadora';
    this.router = router;
    config.map(routes);
  }
}

Error

enter image description here

like image 728
DanyNsg Avatar asked Sep 07 '17 05:09

DanyNsg


1 Answers

Aurelia provides PLATFORM.moduleName("moduleId") to resolve modules, it comes with the aurelia-pal package.

In use it looks like this:

{ moduleId: PLATFORM.moduleName("components/home/home") }
like image 100
DanyNsg Avatar answered Oct 13 '22 06:10

DanyNsg