Reddy Reddy - 1 year ago 181
TypeScript Question

Typescript unable to find Express module

I am trying to create my first NodeJS application, however I couldn't make it work.

These are the steps I followed so far from various blogs and trying to build first nodejs app in typescript.

npm install -g express-generator
npm install -g typescript
express SampleApp
npm install -g typings
typings install dt~node --global
typings install dt~express dt~serve-static dt~express-serve-static-core --global
cd SampleApp
npm install


import express = require('express');
var app = express();

When I build compile the ts file with TypeScript

>>> tsc -m commonjs -t es5 hello.ts
hello.ts(1,26): error TS2307: Cannot find module 'express'.

I have gone through various resources, couldn't find the solution.
I guess I don't have to copy node.d.ts and express.d.ts files manually to the project folder.

If I use nodejs and expressjs alone
npm start
it works fine.
plugin is something I am not able to do

Can anyone help what exactly I am doing wrong here?

Answer Source

I fixed this issue by uninstalling typings package and reinstall typings with --global --save

1. npm uninstall typings --global
2. npm install typings --global
3. typings install dt~node dt~express --global --save

then typescript files are getting compiled fine.

Reported Issue:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download