react-i18next: Updating to webpack 2 and webpack-dev-server: Cannot find module

Hi,

I tried out the example, but updating to webpack 2 (we’re trying to update on a project). But we’re getting a series of errors:

app.js:12781 Uncaught Error: Cannot find module "react-i18next"
    at webpackMissingModule (app.js:12781)
    at Object.<anonymous> (app.js:12781)
    at __webpack_require__ (app.js:20)
    at Object.<anonymous> (app.js:31928)
    at __webpack_require__ (app.js:20)
    at validateFormat (app.js:66)
    at app.js:69
app.js:12847 [WDS] Errors while compiling. Reload prevented.
app.js:12925 ./app/main.js
Module not found: Error: Can't resolve 'react-i18next' in '/Users/me/react-i18next/example/app'
 @ ./app/main.js 11:20-44
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./app/main.js
errors @ app.js:12925
app.js:12925 ./app/components/View.js
Module not found: Error: Can't resolve 'react-i18next' in '/Users/me/react-i18next/example/app/components'
 @ ./app/components/View.js 15:20-44
 @ ./app/components/App.js
 @ ./app/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./app/main.js
errors @ app.js:12925
app.js:12925 ./app/components/AnotherComponent.js
Module not found: Error: Can't resolve 'react-i18next' in '/Users/me/react-i18next/example/app/components'
 @ ./app/components/AnotherComponent.js 11:20-44
 @ ./app/components/View.js
 @ ./app/components/App.js
 @ ./app/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./app/main.js
errors @ app.js:12925
app.js:12925 ./app/components/YetAnotherComponent.js
Module not found: Error: Can't resolve 'react-i18next' in '/Users/me/react-i18next/example/app/components'
 @ ./app/components/YetAnotherComponent.js 11:20-44
 @ ./app/components/View.js
 @ ./app/components/App.js
 @ ./app/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./app/main.js

When I dig through the webpack transpiled code I see a bunch of other modules (i.e. I18nextProvider but not react-i18next.

You can see my fork here: https://github.com/nicolechung/react-i18next/commit/9a2e90a551875ebe2772d4408483e1d0bfbff875

It would be great if you can have a webpack 1 sample AND a webpack 2 sample.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (22 by maintainers)

Most upvoted comments

did you change https://github.com/i18next/react-i18next/blob/master/example/package.json#L29 to not using the build file but the version published on npm? "react-i18next": "^2.0.0"

the sample will be updated to webpack2 when i find the time - webpack1 got deprecated the last days - so no sense in keeping a sample for webpack1.

Yes! That totally works!

Do you have a lot of Typescript users, should I file a PR to update the docs for Typescript people?

Not sure but shouldn’t it be:

import i18n from 'i18next'
import XHR from 'i18next-xhr-backend'
import LanguageDetector from 'i18next-browser-languagedetector'

or change your export to:

export default i18n.default;

As the exports that should be used are on default (we export the functions too - but that won’t work on export i18n again).