Issue encountered: XHR error (404 Not Found) occurred following the installation of typescript-collection in Angular 2 final version

After setting up an Angular 2 project quickly, I added the typescript-collections package using the command:

npm install typescript-collections --save

However, upon launching my project, I encountered the following error:

GET http://localhost:63342/IMA%20Sentinel/node_modules/typescript-collections 404 (Not Found)
Error: Error: XHR error (404 Not Found) loading http://localhost:63342/IMA%20Sentinel/node_modules/typescript-collections
        at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:63342/IMA%20Sentinel/node_modules/zone.js/dist/zone.js:636:29)
        at ZoneDelegate.invokeTask (http://localhost:63342/IMA%20Sentinel/node_modules/zone.js/dist/zone.js:225:37)
        at Zone.runTask (http://localhost:63342/IMA%20Sentinel/node_modules/zone.js/dist/zone.js:125:47)
        at XMLHttpRequest.ZoneTask.invoke (http://localhost:63342/IMA%20Sentinel/node_modules/zone.js/dist/zone.js:293:33)
    Error loading http://localhost:63342/IMA%20Sentinel/node_modules/typescript-collections as "typescript-collections" from http://localhost:63342/IMA%20Sentinel/app/history.service.js

The issue seems to be related to my history.service.ts file where a dictionary is being used:

import { Injectable } from '@angular/core';
import { Dto } from './dto';
import Collections = require('typescript-collections');

@Injectable()
export class HistoryService {

  public managedDtoDico : Collections.Dictionary<number, Dto> = new Collections.Dictionary<number, Dto>();

The package is located here: [projectName]\node_modules\typescript-collections

This is what my tsconfig.json looks like:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  }
}

Do you see anything that might be causing the error?

UPDATE: The systemjs.config.js file has the following configuration:

/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // other libraries
      'rxjs':                       'npm:rxjs',
      'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
      'typescript-collections': 'npm:typescript-collections'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      'angular2-in-memory-web-api': {
        main: './index.js',
        defaultExtension: 'js'
      }
    }
  });
})(this);

Answer №1

Finally figured it out, I discovered the missing piece in the system configuration file:

  ,
  'custom-module': {
    main: './dist/app/main.js',
    defaultExtension: 'js'
  }

Success at last!

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

Angular 2: Streamlining user interface connections with extensive data rows

My challenge lies in displaying a list of items stored in an array[] when the user clicks on a tab. The data set contains around 10k rows, which is quite large, and currently takes approximately 2 to 3 seconds to render on the UI after the click event. I a ...

Exploring the Fusion of GLTF Animations within Three.js in an Angular Environment

Currently, I am diving into an Angular project and have scoured the internet for solutions without any luck in determining a way forward. The challenge at hand involves 3 GLTF files portraying different facial expressions of a model (smiling, crying, laugh ...

Positioning the Angular material menu items in the UI

Hey there! I'm looking to create a mat-menu that opens to the left. I found some code snippets on StackBlitz, check it out: https://stackblitz.com/edit/angular-material-menu-position-aside-6ab669?file=src/app/menu-overview-example.html The menu str ...

The information is failing to display properly within the mat-menu

Recently, I've been working on creating a navbar that includes a submenu. Even though the navigation bar data is loading properly, I am facing some issues with the submenu functionality. As a beginner in this area, I would appreciate any help or guida ...

Running the command `$ yarn install` results in an error message saying "yarn-berry.js

I'm a newcomer to React and I'm encountering an issue with the yarn install command that is producing the following error message: Error: Cannot find module '/Users/MacPro/Desktop/Developer/React/.yarn/releases/yarn-berry.js' at Funct ...

Error message: Module 'firebase/app' not found in angular framework

I am currently working through a Google codelab, which can be found at this link: Check out the codelab here However, when I attempt to build the project using 'ng build --prod', I encounter the following error: ERROR in node_modules/@angular ...

Every time I attempt to use interpolation in Angular 11, the result ends up being displayed as plain text on

I'm a beginner in Angular and I recently attempted my first code following a tutorial. When running this code on a live server using port 5500, I encountered an issue with interpolation. <h1>{{title}}</h1> The result on the webpage displa ...

Mastering the correct method for passing $NODE_DEBUG_OPTION to npm-run-all in IntelliJ IDEA

Running on my system with Ubuntu 16.04, I have IntelliJ IDEA Ultimate 2017.2, node v6.11.2, and npm v3.10.10. I am trying to debug a node.js application that has the following package.json start entry: "start:" "npm-run-all --parallel serve-static open-st ...

Angular 6 allows for the use of radio buttons to dynamically enable or disable corresponding fields

Here is the HTML code for a row containing radio button selections: <div class="form-row"> <div class="col-md-3 mb-3"> <div class = "form-group form-inline col-md-12 mb-3"> <div class="form-check form-check-inl ...

React hook triggering re-render

A function has been implemented to retrieve and decode user claims from a token stored in local storage using a hook. export const useActiveUser = (): { user: IUserTokenClaims | null } => { const [user, setUser] = useState<IUserTokenClaims | nul ...

`A bug in my Angular 4 application causes a TypeError when hosted on IIS`

After hosting an Angular 4 app on IIS, it seems there is an issue when accessing the app from machines other than the ones used for development. An error message " 'Uncaught TypeError: undefined is not a function' common.es5.js:3084" appears on t ...

Implementing reduce for filtering and mapping in TypeScript: A comprehensive guide

I encountered a problem with my code that I need help fixing. Here is a simple example: interface employer { name: string; age: number; } const arr: employer[] = [{name:'Amy',age:18},{name:'Bob',age:20}]; l ...

Establish a local binding context within an Angular template

If I have a complex object structure that I need to bind to: <div>{{model.rootProperty}}</div> <div> <div>{{model.some.deeply.nested.property.with.a.donut.name}}</div> <div>{{model.some.deeply.nested.property.w ...

Problem with connecting Angular data

<body ng-app="myAPP"> <div ng-controller="employeeCtrl"> <table style="border:1px solid gray"> <tr> <th>Employee Name</th> <th>Employee Address</th> <th> ...

Having trouble setting up tailwind css for my Angular project, need some help

Initially, I was referencing this article (along with others): https://medium.com/@jacobneterer/angular-and-tailwindcss-2388fb6e0bab I've been attempting to integrate Tailwind into my Angular project without success. Additionally, I even started an A ...

The parameter '{ validator: any; }' cannot be assigned to the ValidatorFn type in this context

I am currently experiencing a challenge while attempting to create a custom validator using Angular. I have created a form for my sign-up page and wanted to ensure that the password and confirm password fields match by implementing a custom validator. Des ...

Tips for setting up a hierarchical mat-table within a parent table that supports expandable rows using Angular Material

Here is the data that I am working with: [ { "_id": "c9d5ab1a", "subdomain": "wing", "domain": "aircraft", "part_id": "c9d5ab1a", "info.mimetype": "application/json", "info.dependent": "parent", ...

Unable to proceed with deployment due to the absence of the 'category' property in the '{}' type

Everything seems to be functioning properly - I can add and remove products, all with the properties I specified in the database. However, my deployment for production is being hindered by some errors that I'm encountering. ERROR in src\app&bsol ...

Protractor enables horizontal scrolling for a Div element

My struggle to scroll to the right persists despite all attempts I experimented with various solutions, but none seem to work await browser.executeScript('arguments[0].scrollIntoView(true)',element.getWebElement()) The issue still remains unr ...

Angular Reactive Forms provide a method to connect a data object with each element within a FormArray

Currently, I am in the process of constructing a reactive form that resembles the image depicted below - In the image, each file (referred to as an attachment in the code) contains multiple agendas. These agendas can be added, updated, and deleted. https ...