Juicy Juicy - 1 month ago 16x
TypeScript Question

TypeScript compiler in Gulp says it cannot find @angular modules but compiles fine

I'm getting a lot of "false" errors when my

task compiles my typescript. Here's the relevant
gulp task

var tsProject = typescript.createProject('tsconfig.json', {noResolve: true});

gulp.task('build-ts', function() {
gulp.src(appDev + '**/*.ts')
gulp.src(appDev + '**/*.+(html|css)')

And these are the errors I get:

[09:38:52] Starting 'default'...
[09:38:52] Finished 'default' after 8.88 ms
ng/app.component.ts(1,27): error TS2307: Cannot find module '@angular/core'.
ng/app.component.ts(5,12): error TS2304: Cannot find name 'module'.
ng/app.module.ts(1,26): error TS2307: Cannot find module '@angular/core'.
ng/app.module.ts(2,31): error TS2307: Cannot find module '@angular/platform-browser'.
ng/app.module.ts(3,31): error TS2307: Cannot find module '@angular/common'.
[09:38:53] TypeScript: 27 semantic errors
[09:38:53] TypeScript: emit succeeded (with errors)
[BS] Proxying:

My tree structure looks like this (simplified):

├── gulpfile.js
├── ng
├── node_modules
├── package.json
├── tsconfig.json
├── typings.json
└── web

All the modules that the Typescript compiler fails to find are actually in
and my final application works fine despite all the errors.

This is my

"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "./app"
"filesGlob": [
"exclude": [
"atom": {
"rewriteTsconfig": true

How can I get rid of these "false positive" errors.


In the gulp.js file the line

var tsProject = typescript.createProject('tsconfig.json', {noExternalResolve: true, noResolve: true});

should be

var tsProject = typescript.createProject('tsconfig.json');

As we want to load external typings.

And also you need to load the typings in the main.ts file on the top :

/// <reference path="../typings/index.d.ts" />

I did clone your project and it compiles without warnings after this.