Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import i18next-browser-language-detector in SvelteKit (vite) using adapter-static #269

Closed
codenius opened this issue Nov 3, 2022 · 1 comment

Comments

@codenius
Copy link

codenius commented Nov 3, 2022

馃悰 Bug Report

In my SvelteKit (using vite) project with adapter-static configured, I cannot build static files, because I get an error when importing i18next-browser-language-detector.

(node:4019) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/project/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetector.js:1
import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1055:15)
    at Module._compile (node:internal/modules/cjs/loader:1090:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
[vite-plugin-svelte-kit] Prerendering failed with code 1
error during build:
Error: Prerendering failed with code 1
    at ChildProcess.<anonymous> (file:///project/node_modules/@sveltejs/kit/src/exports/vite/index.js:442:15)
    at ChildProcess.emit (node:events:513:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

To Reproduce

  1. create sveltekit project with npm create svelte (with typescript enabled)
  2. install adapter-static and configure in svelte.config.*
  3. install i18next-browser-language-detector and import anywhere with import LanguageDetector from 'i18next-browser-language-detector'
  4. run npm run build to build static files

Expected behavior

No errors and success when running npm run build

Your Environment

  • runtime version: node v16
  • i18next version: 22.0.2
  • vite version: 3.1.0
@adrai adrai closed this as completed in 07c2c50 Nov 3, 2022
@adrai
Copy link
Member

adrai commented Nov 3, 2022

Can you try with v7.0.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants