Static GitHub Issues

[1138] TypeError: app.use() requires middleware functions (using nuxt ^1.0.0-alpha.3)

prev: Using a global event bus
next: Integration of google analytics

can someone help me, error from here :smile:

import Nuxt from 'nuxt'
import express from 'express'

const app = express()
const host = process.env.HOST || '127.0.0.1'
const port = process.env.PORT || 3000

app.set('port', port)

// Start nuxt.js
async function start() {
  // Import and Set Nuxt.js options
  let config = require('../nuxt.config.js')
  config.dev = !(process.env.NODE_ENV === 'production')
  // Instanciate nuxt.js
  const nuxt = new Nuxt(config)
  // Add nuxt.js middleware
  app.use(nuxt.render) # !!!!! error here (seems like) !!!!!!!
  // Listen the server
  app.listen(port, host)
  console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
}

start()

full error on yarn run dev (backpack dev)

 DONE  Compiled successfully in 65ms                                                                                          9:44:32 PM

(node:11837) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: app.use() requires middleware functions
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1003">#c1003</a>)</em></sub></div>