question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'use' of undefined

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

33reactions
isaachinmancommented, Mar 1, 2019

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.

16reactions
isaachinmancommented, Feb 28, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
TypeError: Cannot read property 'use' of undefined Express
You are missing to pass app as argument at Index.js import express from 'express'; const app = express() import {registerRoutes} from '.
Read more >
UnhandledPromiseRejectionWar...
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'use' of undefined #210 · Describe the bug. Promise error · Occurs in next- ...
Read more >
[Solved]-Cannot read property 'use' of undefined-node.js
You should first declare the app : var app = connect();. and then call the use method. app.use(doFirst); app.use(doSecond);.
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found