Comments (8)
@alivadjid 我也有类似的问题,我找到了一个折衷方案,希望能够帮助到您,下方是我的的配置:(I have similar problems. I have found a compromise that I hope will help you. Below is my configuration:)
ssr: {
/**
* 由于在 build 时会报错 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.
* 所以要添加以下配置。详见:https://vite-plugin-ssr.com/common-issues 与 https://vite-plugin-ssr.com/invalid-esm#solution
*/
noExternal: ['vue-i18n']
}
from bundle-tools.
after some updates error changed
from bundle-tools.
The same error with @intlify/unplugin-vue-i18n 0.8.2
file:///srv/app/dist/server/entry-server.js:8
import { useI18n, createI18n } 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 { useI18n, createI18n } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
from bundle-tools.
我也遇见类似的问题,我是在项目中集成了vuepress2
,想在vuepress
展示自己开发的组件。结果导致无法执行pnpm docs:build
。异常信息如下:
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;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
ELIFECYCLE Command failed with exit code 1.
from bundle-tools.
Well, for solve this error i removed i18n from project, and tried to use self-written package for internationalization.
from bundle-tools.
@alivadjid, The issue is with the Vite plugin unplugin-vue-i18n
, not vue-i18n
. The unplugin-vue-i18n
plugin is optional for vue-i18n
. You can import messages yourself, as described in the documentation.
However, it is very sad that the declared functionality of this plugin does not work.
from bundle-tools.
@WangJincheng4869 Your solution fixed my production build but then I could not start my App in dev mode anymore ("module not found"). I uninstalled unplugin-vue-i18n and used vue-i18n directly and now it works in dev and prod.
from bundle-tools.
@WangJincheng4869 Your solution fixed my production build but then I could not start my App in dev mode anymore ("module not found"). I uninstalled unplugin-vue-i18n and used vue-i18n directly and now it works in dev and prod.
use
const isProduction = process.env.NODE_ENV === 'production';
to do some special case in vite config file.
from bundle-tools.
Related Issues (20)
- @intlify/unplugin-vue-i18n doesn't work with Nuxt 3.7 HOT 1
- Missing dependencies and missing MessageFunctionInternal definition HOT 1
- can not inclue js locale files HOT 2
- Changelog of unplugin-vue-i18n is not up to date HOT 3
- @intlify/unplugin-vue-i18n not support HMR with Static bundle importing HOT 1
- Dependency Dashboard
- Module parse failed: Unexpected token (1:0) when combined with html-webpack-plugin HOT 14
- Failed locale loading: Unexpected token 'const'. HOT 1
- Rollup 4 support HOT 1
- `onlyLocales` not working for SFC <i18n locale="xx">
- it is not installed using npm install HOT 1
- Webpack build does not work together with html-webpack-plugin HOT 2
- Using HTML in SFC results in parsing issue `Unexpected scalar at node end` HOT 2
- nuxt3国际化报错 HOT 1
- Missing compile function in SSR build
- Is it possible to make a linkage with i18n Ally HOT 2
- Generated `messages` virtual file contains syntax error when some locale files written in yaml is empty HOT 2
- Get cryptic error `Cannot read properties of undefined (reading 'message')` for a simple problem HOT 1
- Unplugin-vue-i18n don't watch for files changes
- Does not work in Vite HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bundle-tools.