SyntaxError: Named export 'createI18n' not found
See original GitHub issueReporting a bug?
import { createI18n, useI18n } from "vue-i18n/dist/vue-i18n.runtime.esm-bundler.js";
^^^^^^^^^^
SyntaxError: Named export 'createI18n' not found. The requested module 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js';
const { createI18n, useI18n } = pkg;
Expected behavior
- pnpm install
- pnpm build
- cd apps/docs
- pnpm build
Reproduction
branch: feat/date
https://github.com/huntersofbook/huntersofbook/tree/feat/date
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11400 @ 2.60GHz
Memory: 17.10 GB / 31.12 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 16.17.0 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 8.15.0 - /usr/bin/npm
Browsers:
Chrome: 104.0.5112.101
npmPackages:
vitepress: 1.0.0-alpha.10 => 1.0.0-alpha.10
Screenshot
No response
Additional context
No response
Validations
- Read the Contributing Guidelines
- Read the Documentation
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
CommonJS modules can always be imported via the default ...
SyntaxError : Named export 'createI18n' not found. The requested module 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js' is a CommonJS module, ...
Read more >Vue-i18n do not have default export - Stack Overflow
And backtrack the key word VueI18n in the import, I found it doesn't have any default export. typescript · vue.js · vue-i18n ·...
Read more >Common Issues - Nuxt Vite
Uncaught SyntaxError: The requested module ... does not provide an export named 'default'. Vite has an issue for pre-bundling dependencies ...
Read more >Breaking Changes - Vue I18n
Vue I18n is no longer a class but a set of functions. Instead of writing new VueI18n() , you now have to call...
Read more >@intlify/vite-plugin-vue-i18n - npm
Vite plugin for Vue I18n. Latest version: 7.0.0, last published: 15 days ago. Start using @intlify/vite-plugin-vue-i18n in your project by ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@productdevbook Thank you as always!
As found out, this issue occurs in builds when SSR is enabled. The
__VUE_PROD_DEVTOOLS__
flag is expected to be set toglobalThis
for vue-i18n.I have tried to enable
__VUE_PROD_DEVTOOLS__
in theconfigure
hook of the vite plugin, but for some reason it is not enabled when SSR. (And I noticed that other flags provided by vue-i18n are not enabled either)I will continue to fix it. Please wait 🙏
@productdevbook Hello! I’ve just released
@intlify/vite-plugin-vue-i18n
v7.0.0-beta.2 Please check it!I’ve checked your awesome hundersofbook! So, I’ve faced the error in it the below:
I seem that date-fns is not to fully support cjs/mjs vite3 SSR (vitepress) requires esm, so you might want to check if your module is supported as a dual module.