kant2002 / gulp-tsc

gulp.js plugin for compiling TypeScript files
MIT License
16 stars 11 forks source link

Failed to compile TypeScript: Error: tsc command has exited with code:2 #27

Closed VladimyrRomanishyn closed 7 years ago

VladimyrRomanishyn commented 7 years ago

Hello, how fix this?

image

gulpfile.js

const gulp = require('gulp');
const nodemon = require('gulp-nodemon');
const ts = require('gulp-tsc');

//-------------------------------------

gulp.task('start', ()=> {
  nodemon({
    script: 'index.js'
  , ext: 'js html'
  , env: { 'NODE_ENV': 'development' }
  })
});
//-------------------------------------
//gulp.watch('client/src/**/*.ts',['script']);
//-------------------------------------
gulp.task('script', ()=>{
    gulp.src('client/src/**/*.ts')
    .pipe(ts({
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": [ "es2015", "dom" ],
        "noImplicitAny": false,
        "suppressImplicitAnyIndexErrors": true,
        "emitError": false
    }));
});
//-------------------------------------
gulp.task('default',['start','script']);
kant2002 commented 7 years ago

@VladimyrRomanishyn could you try with version 1.3

VladimyrRomanishyn commented 7 years ago

Node_modules errors disappeared, but " Failed to compile ..." still the same. Via native tsc compiler from terminal all works, but I must do it every time manually. image

kant2002 commented 7 years ago

@VladimyrRomanishyn this one looks like you miss "es5" in the "lib"

VladimyrRomanishyn commented 7 years ago

here my gulpfile.js, changed "es2015" to "es5", but still the same(

const gulp = require('gulp');
const nodemon = require('gulp-nodemon');
const ts = require('gulp-tsc');

//-------------------------------------

gulp.task('start', ()=> {
  nodemon({
    script: 'index.js'
  , ext: 'js html'
  , env: { 'NODE_ENV': 'development' }
  })
});
//-------------------------------------
//gulp.watch('client/src/**/*.ts',['script']);
//-------------------------------------
gulp.task('script', ()=>{
    gulp.src('client/src/**/*.ts')
    .pipe(ts({
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": [ "es5", "dom" ],
        "noImplicitAny": false,
        "suppressImplicitAnyIndexErrors": true,
        "emitError": false
    }));
});
//-------------------------------------
gulp.task('default',['start','script']);
kant2002 commented 7 years ago

You should have both "es5" and "es2015", something like that.

gulp.task('script', ()=>{
    gulp.src('client/src/**/*.ts')
    .pipe(ts({
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": [ "es5", "es2015", "dom" ],
        "noImplicitAny": false,
        "suppressImplicitAnyIndexErrors": true,
        "emitError": false
    }));
});