В настоящее время я сталкиваюсь с странной проблемой при загрузке модуля с Aurelia. Я успешно загрузил библиотеку moment
для дат форматирования, однако я пытаюсь загрузить библиотеку numeral
точно так же с помощью npm install <module> --save
, но она пытается найти библиотеку numeral
в каталоге /dist
, а не библиотеке модулей.Модуль не загружается в Aurelia
У меня есть два ValueConverters ниже:
кода с использованием Moment
:
SRC/фильтры/время-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
:
SRC/фильтры/температурно-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>
Я получаю следующее сообщение об ошибке при попытке увидеть страницу с помощью numeral
:
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
Почему пытается заглянуть в каталог /dist
, а не библиотеки модуля? Я знаю, что есть некоторый разрыв в инъекции зависимостей, но я не уверен, что с этим делать.
Учитывая упоминание '/ dist ', @cchapman вряд ли будет использовать Aurelia CLI. –
Хороший улов. Благодаря! Мой ответ будет работать только с CLI. – LStarky