3

I am trying to write a node app using typescript with the gulp. In which i am writing server.ts file typescript as

import express from 'express';
import mongoose from 'mongoose';


let app=express();
app.set('port', process.env.PORT || 3000); // Set port to 3000 or the provided PORT variable


/**
 * Start app
 */
app.listen(app.get('port'), function() {
  console.log(`App listening on port ${app.get('port')}!`);
});

i have use the gulp to compile and place in src folder from which i will run my app

here is my gulpfile code:

var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var tsc = require('gulp-typescript');
var config = require('./gulp.config')();
var tsProject = tsc.createProject('tsconfig.json');



gulp.task('compile', function() {
  var sourceTsFiles = [
        config.allTs,
        config.typeings,
    ];
    var tsResult = gulp
        .src(sourceTsFiles)
        .pipe(sourcemaps.init())
        .pipe(tsc(tsProject));

    return tsResult.js
        .pipe(sourcemaps.write('./map'))
        .pipe(gulp.dest(config.tsOutPutPath));
});


gulp.task('default', function() {
  // place code for your default task here
});

here is my gulp.config file

module.exports = function () {
    var config = {
        allTs:'./server.ts',
        typeings:'./typings/**/*.ts',
        tsOutPutPath:'./src'
    };
    return config;
}

when i run my gulp task i am getting error cannot find module

enter image description here

I wondering why i getting this error please correct me if i making anything wrong.

1 Answer 1

1

I have did the silly mistake that i have not install the typing for those modules. install the all the typing all modules and its dependency its stat working fine.

Sign up to request clarification or add additional context in comments.

1 Comment

Can you elaborate your solution, please? :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.