Reputation: 3700
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
I wondering why i getting this error please correct me if i making anything wrong.
Upvotes: 3
Views: 319
Reputation: 3700
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.
Upvotes: 1