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);