why vue-i18n cannot build with vite-ssg
See original GitHub issueI’m running the vite-ssg build, but the console always show these informations:
[vite-ssg] An internal error occurred. [vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues (node:17492) UnhandledPromiseRejectionWarning: file:///E:/01_Workstation/03_Codes/Vue3/whatever-fronted/.vite-ssg-temp/main.mjs:3 import { createI18n, useI18n } from ‘vue-i18n/dist/vue-i18n.runtime.esm-bundler.js’; ^^^^^^^ SyntaxError: Named export ‘useI18n’ 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 (internal/modules/esm/module_job.js:124:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:179:5)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async build (file:///E:/01_Workstation/03_Codes/Vue3/whatever-fronted/node_modules/.pnpm/vite-ssg@0.20.2_gv3f3qqio2remjcjfesyn4w42y/node_modules/vite-ssg/dist/chunks/build.mjs:171:87)
at async Object.handler (file:///E:/01_Workstation/03_Codes/Vue3/whatever-fronted/node_modules/.pnpm/vite-ssg@0.20.2_gv3f3qqio2remjcjfesyn4w42y/node_modules/vite-ssg/dist/node/cli.mjs:20:3)
(Use node --trace-warnings ...
to show where the warning was created)
(node:17492) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:17492) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I don’t why cause this problem
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top GitHub Comments
Update your ssr configuration in vite.config.ts:
I think this should work for other packages too.
I ran into this problem and get the error regardless of whether my
type
is set to “module” or “commonjs”.