Stack
Hi, I am bootstrapping a MEAN stack application. We are using Angular2 and typescript. Gulp is used for the build. I develop on a MAC OS machine.
Issue
When I run my application locally as always with gulp watch
and open localhost:3000
my Angular application does not load and I have in my JavaScript Console the following error :
When I google this issue, I found these articles :
- Angular2 + Jspm.io : reflect-metadata shim is required when using class decorators
- https://github.com/AngularClass/angular2-webpack-starter/issues/353
Seem they both advice to add 2 supposed missing imports :
import 'zone.js';
import 'reflect-metadata';
But I have in my vendor.ts
file already these two imports :
import 'zone.js/dist/zone';
import 'reflect-metadata';
After running gulp watch
I have the following content in my transpiled vendor.js
file
"use strict";
require('shim');
require('rxjs/add/operator/map');
require('validate.js');
require('zone.js/dist/zone');
require('reflect-metadata');
require('@angular/core');
require('@angular/common');
require('@angular/platform-browser-dynamic');
require('@angular/router-deprecated');
require('@angular/http');
But when I compare this vendor.js
file with my friend who runs gulp watch
on a (windows) machine, they are very different. His vendor.js
file has way more generated code in that file. (2000+ lines). When I copy the content of his vendor.js
file into my vendor.js
file, the solution works locally. But obviously after every build, the content will be regenerated and cause the same issue.
Solutions
I have tried to run typings install
, npm install
and npm cache clear
already a few times but I fail to get the solution running locally. I have no pending local changes, neither does my friend who is able to run it.
So has anyone an idea in what I have to look into to figure out why the vendor.js
is not well generated ?
Thank you for your time
EDIT 1
As requested my 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"
]
}
EDIT 2
Funny fact : When I am watching my solution with gulp watch
and I edit my vendor.ts
with a simple new line for example, and I refresh my page after the watch picked up the change, everything works. But when I stop my watch en run again gulp watch
I face the same issue again.