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.

Error: Cannot find module 'next-i18next/middleware'

See original GitHub issue

I followed every step in configuration, have the same setup for server.js and i18n.js but still getting this error whenever I try to run yarn dev:

module.js:550
    throw err;
    ^

Error: Cannot find module 'next-i18next/middleware'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/dev/Projekty/AdTom/front/app.js:3:31)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)

This is my server.js:

const express = require('express')
const next = require('next')
const nextI18NextMiddleware = require('next-i18next/middleware')

const nextI18next = require('./lib/i18n')

const app = next({ dev: process.env.NODE_ENV !== 'production' })
const handle = app.getRequestHandler();

(async () => {
  await app.prepare()
  const server = express()

  nextI18NextMiddleware(nextI18next, app, server)

  server.get('*', (req, res) => handle(req, res))

  await server.listen(3000)
})()

and these are package versions:

node: 8.14.0

"express": "^4.16.4"
"next": "^7.0.2"
"next-i18next": "^0.8.0"
"react": "^16.6.3"

What else needs to be done to run it ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

9reactions
latchycommented, Nov 11, 2020

Hi @isaachinman, could you please add an example that uses the latest version of next-i18next (v6) with a custom express server? I keep going around in circles trying to get this to work. Thanks

7reactions
isaachinmancommented, Aug 5, 2020

@lcvbeek It’s not “supported” anymore because it’s not necessary. We were able to replace the functionality with built-in features of NextJs, as soon as rewrites dropped. The middleware you mentioned is already/still used by next-i18next, just in a serverless manner.

You can still use a custom server if you really want to, but next-i18next no longer has anything to do with that.

Let me know if that makes sense.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'react-i18next' - Stack Overflow
export default MyComponent; I get the following error: Cannot find module 'react-i18next'.
Read more >
next-i18next - npm
First, create a next-i18next. config. js file in the root of your project. The syntax for the nested i18n object comes from Next....
Read more >
kglogins - Netlify Support Forums
My code is based on this example from the next-i18next repo: ... Build with next-i18next error: Error: Cannot find module '.
Read more >
Advanced Features: Internationalized Routing - Next.js
The default locale does not have a prefix. Domain Routing. By using domain routing you can configure locales to be served from different ......
Read more >
Module not found | Can't resolve 'fs' in Next js application
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
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