Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install express in typings?

I am trying to use expressjs in my app.

After installing it using typings install express --ambient --save, I run tsc, but I get two errors:

typings/main/ambient/express/index.d.ts(17,34): error TS2307: Cannot find module 'serve-static'. typings/main/ambient/express/index.d.ts(18,27): error TS2307: Cannot find module 'express-serve-static-core'.

So, I tried to install both:

typings install serve-static --ambient --save
typings install express-serve-static --ambient --save

and then I run tsc again, but get one more error:

typings/main/ambient/serve-static/index.d.ts(79,24): error TS2307: Cannot find module 'mime'.

How can I solve these problems? How can I install all dependencies of express automatically?

like image 587
MuriloKunze Avatar asked Mar 16 '16 14:03

MuriloKunze


People also ask

Is Express installed with node?

The Express development environment includes an installation of Nodejs, the npm package manager, and (optionally) the Express Application Generator on your local computer.

Do I need to install Express for every project?

Yes, install Express and other NPM components separately for each project. This way, you keep each project independent from the others and you can upgrade components in one without affecting all the others. Each project then has its own package.


1 Answers

With Typescript 2.0(https://blogs.msdn.microsoft.com/typescript/2016/09/22/announcing-typescript-2-0/), now it is different:

If you install typescript with the following command:

npm install -g [email protected]

You will have to install express typings with command

npm install --save @types/express

Instead of typings getting installed with ambient/global like in earlier releases. The typings get installed in node_modules/@types/express directory

Your package.json will have the following fragment after doing npm install of types :

"dependencies": {
    "@types/express": "^4.0.33"
  }
like image 94
randominstanceOfLivingThing Avatar answered Oct 03 '22 14:10

randominstanceOfLivingThing