I have attempting to set up a simple application in Angular2, NodeJS and TypeScript but am having errors getting the Angular2 application error to instantiate. I am getting the following errors:
es6-shim.js:1 Uncaught SyntaxError: Unexpected token <
angular2-polyfills.js:1 Uncaught SyntaxError: Unexpected token <
system.src.js:1 Uncaught SyntaxError: Unexpected token <
Rx.js:1 Uncaught SyntaxError: Unexpected token <
angular2.dev.js:1 Uncaught SyntaxError: Unexpected token <
http.dev.js:2 Uncaught ReferenceError: System is not defined(anonymous function) @ http.dev.js:2
(index):15 Uncaught ReferenceError: System is not defined
I am unsure as to why this is happening? It seems to be an issue with my index.html file that calls all of the Angular2 script dependencies and then instantiates the SystemJS functionality. Here is that file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Angular 2 Quick Start</title>
<base href="/"/>
<script src="../node_modules/es6-shim/es6-shim.js"></script>
<script src="../node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="../node_modules/systemjs/dist/system.src.js"></script>
<script src="../node_modules/rxjs/bundles/Rx.js"></script>
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/http.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/app')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
My app.ts file in relation to the index.html file is in a folder called app so that is correct.
Can anyone shed any light as why I will be getting this error?I am thinking it might be a SystemJS error but I can't figure it out!
Here is a picture of the file structure.
Here is my NodeJS entry-point file:
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var logger = require('morgan');
var port = process.env.PORT || 3006;
var app = express();
// view engine setup
app.set('views', path.join('./client'));
app.set('view engine', 'jade');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use('/app', express.static(path.resolve(__dirname, 'app')));
app.use('/libs', express.static(path.resolve(__dirname, 'libs')));
var renderIndex = function (req, res) {
res.sendFile(path.resolve('./client/index.html'));
};
app.get('/*', renderIndex);
var server = app.listen(port, function () {
var host = server.address().address;
var port = server.address().port;
console.log('This express app is listening on port:' + port);
});
Thanks