I've encountered a peculiar issue while attempting to load a module using Aurelia. The moment
library was successfully loaded for date formatting, but when trying to load the numeral
library in the same manner with
npm install <module> --save
, it's searching for the numeral
library in the /dist
directory instead of the module library.
Below are two ValueConverters:
Moment Example:
src/filters/time-format.js
import moment from 'moment';
export class TimeFormatValueConverter {
toView(value) {
return moment(value).format('h:mm');
}
}
src/clock.html
<template>
<require from="./filters/date-format"></require>
<require from="./filters/time-format"></require>
<section class="au-animate">
<h2 class="clock-font-large">${time | timeFormat}</h2>
</section>
</template>
Numeral Example:
src/filters/temperature-format.js
import numeral from 'numeral';
export class TemperatureFormatValueConverter {
toView(value) {
return numeral(value).format('(00)');
}
}
src/weather.html
<template>
<require from="./filters/temperature-format"></require>
<section class="au-animate">
<h2 class="clock-font-large">${weather.main.temp | temperatureFormat }</h2>
</section>
</template>
Upon attempting to use Numeral
, I'm encountering the following error:
ERROR [app-router] Error: (SystemJS) XHR error (404 Not Found) loading http://clock.localhost:9000/dist/numeral.js
Error: XHR error (404 Not Found) loading http://clock.localhost:9000/dist/numeral.js
Error loading http://clock.localhost:9000/dist/numeral.js as "numeral" from http://clock.localhost:9000/dist/filters/temperature-format.js
Why is it looking in the /dist
directory rather than the module library? It seems there may be an issue with dependency injection, but the solution is not clear to me.