title: nodejs + express: Cors is not a function
body: <p>Been working fine up until this morning and now, suddenly i am getting a type error stating that <code>Cors is not a function</code></p>
  
  <p>My code</p>
  
  <pre><code>import * as Cors from "cors";
  ...
  
  const corsOptions: Cors.CorsOptions = {
      allowedHeaders: ["Origin", "X-Requested-With", "Content-Type", "Accept", "X-Access-Token", "Authorization"],
      credentials: true,
      methods: "GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE",
      origin: "*",
      preflightContinue: true
  };
  
  createConnection(ormConfig).then(async connection =&gt; {
      // run pending migrations
      await connection.runMigrations();
      // create express server
      const app = express();
      app.use(bodyParser.json({limit: "50mb"}));
      app.use(bodyParser.urlencoded({limit: "50mb", extended: true}));
      // register cors
      app.use(Cors(corsOptions)); //&lt;---error occurs here
      // register all controllers
      useExpressServer(app, {
          routePrefix: "/api",
          controllers: [
              __dirname + "/controllers/**/*{.js,.ts}"
          ],
          authorizationChecker: async (action: any, roles: string[]) =&gt; {
              return JwtAuthorizationMiddleware.checkIsAuthorized(action, roles);
          },
          currentUserChecker: async (actions: any) =&gt; {
              return JwtAuthorizationMiddleware.extractUserFromJwtToken(actions);
          }
      });
  
      // start the express server
      const port: number = +(process.env.PORT || 44320);
      app.listen(port, (err: Error) =&gt; {
          console.log(`App listening on port ${port}`);
          console.log("Press Ctrl+C to quit.");
      });
  }).catch(error =&gt; console.error("TypeORM connection error: ", error));
  </code></pre>
  
  <p>Current versions of cors and Node</p>
  
  <pre><code>cors: "^2.8.4"
  Node: v8.4.0
  </code></pre>
  
  <p>The only change that recently done was on Friday when I included the following packages</p>
  
  <pre><code>multer: "^1.3.0"
  @google-cloud/datastore: "^1.1.0"
  @google-cloud/storage: "^1.4.0"
  </code></pre>
  
  <p>and everything was working till this morning, same version is deployed on gcloud and this works so I am a little bemused as to why I Am suddenly getting this error and what could be the cause.</p>
  
  <p>Any help is greatly appreciated</p>