Answer the question
In order to leave comments, you need to log in
How to install vue-i18n + typescript?
Hello, I have created an empty vue 3 project with TypeScript and run it and vue add i18n
then I get
This dependency was not found:
* vue-i18n in ./src/i18n.ts
To install it, you can run: npm install --save vue-i18n
This dependency was not found:
* vue-i18n in ./src/i18n.ts
To install it, you can run: npm install --save vue-i18n
ERROR in src/i18n.ts:1:10
TS2614: Module '"../node_modules/vue-i18n/types"' has no exported member 'createI18n'. Did you mean to use 'import createI18n from "../node_modules/vue-i18n/types"' instead?
> 1 | import { createI18n, LocaleMessages, VueMessageType } from "vue-i18n";
| ^^^^^^^^^^
2 |
3 | /**
4 | * Load locale messages
ERROR in src/i18n.ts:1:38
TS2614: Module '"../node_modules/vue-i18n/types"' has no exported member 'VueMessageType'. Did you mean to use 'import VueMessageType from "../node_modules/vue-i18n/types"' instead?
> 1 | import { createI18n, LocaleMessages, VueMessageType } from "vue-i18n";
| ^^^^^^^^^^^^^^
2 |
3 | /**
4 | * Load locale messages
ERROR in src/i18n.ts:9:32
TS2315: Type 'LocaleMessages' is not generic.
7 | * See: https://github.com/intlify/vue-i18n-loader#rocket-i18n-resource-pre-compilation
8 | */
> 9 | function loadLocaleMessages(): LocaleMessages<VueMessageType> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 | const locales = require.context(
11 | "./locales",
12 | true,
ERROR in src/i18n.ts:15:19
TS2315: Type 'LocaleMessages' is not generic.
13 | /[A-Za-z0-9-_,\s]+\.json$/i
14 | );
> 15 | const messages: LocaleMessages<VueMessageType> = {};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 | locales.keys().forEach((key) => {
17 | const matched = key.match(/([A-Za-z0-9-_]+)\./i);
18 | if (matched && matched.length > 1) {
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question