Say I have a foo.ts and app.ts as follows:
foo.ts:
export interface Foo {
id: number;
label: string;
};
app.ts:
import {Foo} from './foo'
var myfoo: Foo = { "id": 1, "label": "One" };
console.log(JSON.stringify(myfoo));
After compiling, executing 'node app.js'
from the command line runs as expected if I use "module"="commonjs"
in my tsconfig.json
. Cutting to the chase, what I would like to do is is use my Foo
interface client-side with Angular 2, and server-side with node. Inconveniently, the Angular 2 quickstart I am modeling on here wants "module"="system"
in tsconfig.json
. This configuration causes an error when trying to run 'node app.js'
:
System.register([], function(exports_1) {
^
ReferenceError: System is not defined`
I have tried following the instructions for using systemjs with node on github, but at this point I am just mashing keys and could use some help. How do I either (a) get my app.ts code running on the server-side using systemjs, or alternately, (b) get the Angular 2 quickstart running with commonjs?
tsd install node express
) for the "typings" and then running node. It's hard to see your problem without all the code. – Fabien Sa Dec 22 '15 at 21:31