Next-i18next: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'use' of undefined

Created on 28 Feb 2019  路  6Comments  路  Source: isaachinman/next-i18next

Describe the bug

Promise error

Occurs in next-i18next version

"next-i18next": "^0.10.2",
"i18next-express-middleware": "^1.7.1",
"i18next": "^15.0.4",

Steps to reproduce

i18n.js

const { localeSubpaths } = require('next/config').default().publicRuntimeConfig
const NextI18Next = require('next-i18next')

module.exports = new NextI18Next({
  otherLanguages: ['th'],
  localeSubpaths,
})

server.js

app.prepare().then(() => {
  server.applyMiddleware(nextI18NextMiddleware(nextI18next))

  server.get('*',(req, res) => {
    handle(req, res, parsedUrl)
  }).listen(port, (err) => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}`)
  })
})

Actual results

(node:33387) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'use' of undefined

Most helpful comment

That doesn't tell me anything, you'd need to post the full error. I'm quite sure you should post this type of question on StackOverflow. Thanks.

All 6 comments

How do you expect me to help with this in any way, whatsoever? Please provide reproducible examples when opening issues, and pay attention to the issue templates - they're there for a reason.

@isaachinman Before that's i use

await server.use(nextI18NextMiddleware(nextI18next))

that's not have promise error but my next js application not return server side rendering

So your server is undefined? Please post on StackOverflow.

馃憤

Here is more detail

next-i18next-middleware.js:21:10)
    at app.prepare.then 
    at process._tickCallback 
(node:33387) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:33387) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

i'm not sure that's error from express

That doesn't tell me anything, you'd need to post the full error. I'm quite sure you should post this type of question on StackOverflow. Thanks.

Was this page helpful?
0 / 5 - 0 ratings