Encountering issues with loading a module in Aurelia

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.

Answer №1

If you're utilizing SystemJS, the recommended command to run is:

jspm install numeral

Unless you have a specific reason to do so, there's no need to install packages using NPM while working with the SystemJS Skeleton.

Answer №2

To integrate Numeral into your Aurelia-cli project, update the aurelia.json file located in the aurelia_project folder with the code snippet provided below:


{
    "name": "numeral",
    "path": "../node_modules/numeral",
    "main": "numeral"
},

Remember that in Aurelia, you must explicitly specify all dependencies.

If you are using the Skeleton installation, refer to Fabio's solution for guidance.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating an environment variable using the package.json script

I'm trying to set the process.env.ENV variable as either TEST or null using a script in my package.json file. The command below is not working when I run it through package.json (though it works fine when directly executed in cmd). script { "star ...

Angular restricts the use of the svg namespace in the $sce service for security reasons

I have a project in Angular Material where I am using an md-icon with a specific svg structure: <md-icon class="ic1" md-svg-src='data:image/svg+xml, <svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 32 32"> <ellipse ry="16" rx=" ...

Having trouble with jQuery attribute selectors? Specifically, when trying to use dynamic attribute

This is the code I am working with $("a[href=$.jqURL.url()]").hide(); $.jqURL.url() fetches the current page URL. Unfortunately, this code is not functioning as expected. Is there a way to dynamically select elements? ...

Creating the correct JSON structureHere is how you can format JSON

I have a snippet of javascript code that I'm utilizing with casperjs to iterate through links and retrieve data in json format. Below is the code snippet: casper.each(links, function (self, link) { this.thenOpen(link, function () { // obtain w ...

What is the recommended element for managing data in React?

Let's consider a scenario where we have 2 main components: class App extends React.Component { state = { comments: [1, 2, 3, 4] } render() { return ( <Comments /> ) } } class Comments extends React.Component { rende ...

Determine the full location information with the help of Google Maps SDK without the need

My current challenge involves dealing with a list of unformatted and incorrectly written addresses. I am seeking a way to iterate through these flawed strings and generate more organized and accurate addresses using one of the many Google Maps SDKs availa ...

Error VM5601:2 encountered - Unexpected token "<" found in JSON at position 10

I am trying to retrieve data using Ajax and jQuery, but I keep encountering an error that I cannot figure out how to fix. VM5601:2 Uncaught SyntaxError: Unexpected token < in JSON at position 10 Below is the code I am working with. Model public f ...

React: Submit button not triggering form submission despite having a valid submit event handler and correct syntax

My question stands out from existing ones as it features valid syntax, correct use of type="submit" on the button, and a simple onSubmit handler on the form. Despite this, clicking the button fails to trigger the onSubmit handler. To illustrate ...

Invoking a function within an HTML file does not result in triggering an alert message

Hello everyone, thank you for taking the time to look at this. I'm attempting to execute a javascript function when I click on the update button. Here is the javascript code: var text2Array = function() { // This function takes the value from the t ...

Using app.js in a blade file can cause jQuery functions and libraries to malfunction

In my Laravel application, I am facing an issue with my vue.js component of Pusher notification system and the installation of tinymce for blog posts. Adding js/app.js in my main layout blade file causes my tinymce and other jQuery functions to stop workin ...

The Axios request for the concatenated URL is failing to execute

Encountering an issue with Axios in node js. Here's the code snippet: let callResult = await axios.get(urlData, config) The configuration object used is as follows: let config = { headers: { 'X-Token': token } ...

Get information that has been uploaded using ajax

I need help with my code for sending data via ajax to an update.php page. $(document).ready(function() { $("#modify").click(function() { var a = $("#a").val(); var b = $("#b").val(); var c = $("#c").val(); $.ajax({ type: "POST", ...

Creating secure paths with ReactJS

I'm currently working on implementing protected routes in my React application. I have a Node.js backend with an endpoint called /isLoggedIn that checks if the user is logged in. The backend functionality is working fine, but I'm encountering mul ...

Seeking a way to keep the returned Ajax string consistent and prevent it from fading away after page transition

I have a form that appears when the user clicks on the "Edit" link, allowing them to input their profile information. Upon submission, the data is processed via Ajax and saved in an SQL database using a PHP script. After saving the new profile, I would lik ...

Is there a way to refresh a specific element without having to reload the entire page when the button is clicked

While working on a rock, paper, scissors game in JavaScript, I found it tedious to have to constantly reload the page after each play. To solve this issue, I attempted to add a button that would reset the game for a new round. However, I encountered an err ...

verifying the presence of offspring in knockout js

Utilizing knockout for displaying items on the page, I have a series of groups such as Group 1, Group 2, etc. Each group is contained within its own div. Upon clicking on a group, it expands to showcase the items within that specific group. However, some o ...

Effective communication among sibling components in Vue.js

Interaction between parent and child components can be easily achieved using $broadcast and $dispatch However, I'm currently faced with a challenge regarding communication between sibling components. My current approach involves triggering a $dispatc ...

Experiencing issues with autoungrabify or autolock in cytoscape.js?

I have been working on a web application using Cytoscape.js, and I recently integrated the Edgehandles extension to allow users to add edges. The two types of edges that can be added are undirected and directed. Adding directed edges is functioning as expe ...

"Utilize a specific parameter in the npm run script for enhanced

Is it possible to pass a named parameter to an npm run script in order to achieve the following functionality? "scripts":{ "say-hello":"echo $greeting && ls" } npm run hello --greeting=hello The desired outcome is to replace the $greeting ...

Begin the Wordpress AJAX Login

Is there a way to trigger the code below when a user is logged out from another location due to user inactivity, similar to how wp-admin displays an AJAX login overlay if a user is logged out? I have not come across any documentation or tutorials on achiev ...