How to install express in typings?
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 typescript@2.0
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" }
{ "globalDependencies": { "express": "registry:dt/express#4.0.0+20160708185218", "express-serve-static-core": "registry:dt/express-serve-static-core#4.0.0+20160715232503", "mime": "registry:dt/mime#0.0.0+20160316155526", "node": "registry:dt/node#6.0.0+20160621231320", "serve-static": "registry:dt/serve-static#0.0.0+20160606155157" }}
This is my working Typings.json
I just ran into this myself and I believe is a duplicate from :
Importing node and express with typings in TypeScript
I installed both serve-static and express-serve-static then got errors stating that I was missing 'mime' and 'http'.
I had to install node typings to resolve the missing http reference and mime typings to resolve mime missing reference.
typings install mime --ambient --savetypings install node --ambient --save