I've followed the starting guide and expanded a little upon for a previous angular 2 version. I've updated my revision and changed everything accordingly. When I am running the web server I now receive the error 404 for traceur...
Relevant files :
Index.html:
<html>
<head>
<title>Kinepolis HR-tool</title>
<base href="./">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Kinepolis HR tool">
<meta name="author" content="Jeffrey Devloo!">
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css" />
<!-- CSS for PrimeUI -->
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
systemjs.config.js
(function(global) {
// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
'rxjs': 'node_modules/rxjs',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'@angular': 'node_modules/@angular',
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { defaultExtension: 'js' },
};
var packageNames = [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router',
'@angular/router-deprecated',
'@angular/testing',
'@angular/upgrade',
];
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
packageNames.forEach(function(pkgName) {
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
map: map,
packages: packages
}
// filterSystemConfig - index.html's chance to modify config before we register it.
if (global.filterSystemConfig) { global.filterSystemConfig(config); }
System.config(config);
})(this);
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
I've had the same issue and it couldn't load one of my files. I opened the file and everything was correctly there.
The problem was that I've had a snippet commented out in the same file. Snippet contained this keyword "export class". Even though it was commented out, it was parsed by Angular.
Make sure that you don't have "export class" keywords in your comments, and delete the temporary commented code just to check if it works without it.
In my case I didn't even had
traceur
as a dependency innode_modules
and the app was working fine but all of a sudden started to ask fortraceur
after adding a library that didn't needtraceur
either.The solution was to reference the newly added libraries from
bundles
folders instead ofsrc
(or default folder) insystem.config.js
and specifying the.umd.js
version of files. Also, I had to remove themain
entry from thepackages
section.The reason behind is that loading the
umd
modules from thebundle
folders does not trigger thetraceur
transpiler as it assumes the library module is already in the correct format. Otherwise, it may assume that the code is written ines2015
and it needs transpilation so it invokestraceur
.I came across this
traceur
issue after trying to connect to aFirebase
instance from a perfectly runnable "Tour of Heroes" app with the aid ofAngularFire2
. I tried all the answers here but none of them helped, so I googled until I found this github issue.The problem is within the system.js I think:
There is a regex, which is used to detect import-statements:
This regex will detect import-statements within multiline-comments and cause this horrible error. I have opened an issue here:
https://github.com/systemjs/systemjs/issues/1408
I have the same issue, after I googled for this case, then I solved it by changed: Core issue: main: 'index.js' must be changed to main: 'bundles/core.umd.js'
=> main: 'bundles/core.umd.js'
Note: My maps:
For me, what happened is a co-worker deleted a TypeScript file, which meant I had an old *.js file no longer needed (since our source control ignores these files). If the traceur error references a *.js file you don't need, delete the file.
At first, you should compile your TypeScript files with
command. If you are running application outside the node envirnoment, you should compile TypeScript files manually.
Also check tsconfig.json - if script version is set as ES6 for Angular 2.0