Imad Imad - 2 months ago 18
TypeScript Question

error TS2307: Cannot find module 'app'

I want to use typescript on node side. I have a very simple server. tsconfig.file inside my server folder is as follows:

"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "../dist/serverBuild",
"typeRoots": [
"exclude": [

I have an app.ts file which has express related configuration in it and then I have server.ts file which is importing app module from app.ts and it has code to create and start the node server.
But I am getting following error:

TSError: тип Unable to compile TypeScript
server.ts (11,22): Cannot find module 'app'. (2307)

other modules that I am importing in my server.ts file like http module is not throwing any such error. What am I doing wrong here.

Here is how I am importing modules:

import * as http from "http";
import * as app from "app";



To load files from your project include the path. Use:

import * as app from './app';

By using from 'app' you are saying there is a module named app installed in your project. If that was the case you would need to install the typings for that module or create it yourself.