Getting weird error in Vue.js 3 while using i18n

I am working on a project where i18n is used, and the loader is ‘@intlify/vue-i18n-loader’. I am working with 2 languages: English and German. I am getting a weird error while running the app.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>ERROR Failed to compile with 1 error 2:59:59 PM
error in ./src/locales/de.json
Module parse failed: Cannot parse JSON: Unexpected token 'e', "export def"... is not valid JSON while parsing 'export default {
"bch": {
"bps": ('
File was processed with these loaders:
* ./node_modules/@intlify/vue-i18n-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
Error: Cannot parse JSON: Unexpected token 'e', "export def"... is not valid JSON while parsing 'export default {
"bch": {
"bps": ('
at JsonParser.parse (/Users/mohitchandel/Documents/front-end/node_modules/webpack/lib/json/JsonParser.js:54:10)
</code>
<code>ERROR Failed to compile with 1 error 2:59:59 PM error in ./src/locales/de.json Module parse failed: Cannot parse JSON: Unexpected token 'e', "export def"... is not valid JSON while parsing 'export default { "bch": { "bps": (' File was processed with these loaders: * ./node_modules/@intlify/vue-i18n-loader/lib/index.js You may need an additional loader to handle the result of these loaders. Error: Cannot parse JSON: Unexpected token 'e', "export def"... is not valid JSON while parsing 'export default { "bch": { "bps": (' at JsonParser.parse (/Users/mohitchandel/Documents/front-end/node_modules/webpack/lib/json/JsonParser.js:54:10) </code>
ERROR  Failed to compile with 1 error                                                                  2:59:59 PM

 error  in ./src/locales/de.json

Module parse failed: Cannot parse JSON: Unexpected token 'e', "export def"... is not valid JSON while parsing 'export default {
  "bch": {
    "bps": ('
File was processed with these loaders:
 * ./node_modules/@intlify/vue-i18n-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
Error: Cannot parse JSON: Unexpected token 'e', "export def"... is not valid JSON while parsing 'export default {
  "bch": {
    "bps": ('
    at JsonParser.parse (/Users/mohitchandel/Documents/front-end/node_modules/webpack/lib/json/JsonParser.js:54:10)

The weird thing is that I have never exported the JSON file mentioned in the Error and the file is in pure JSON format.

Here is my vue.config.js

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>const CircularDependencyPlugin = require("circular-dependency-plugin");
const ReplaceInFileWebpackPlugin = require("replace-in-file-webpack-plugin");
const webpack = require("webpack");
const path = require("path");
process.env.VUE_APP_VERSION = require("./package.json").version;
module.exports = {
chainWebpack: (config) => {
config.optimization.minimizer("terser").tap((args) => {
args[0].terserOptions.output = {
...args[0].terserOptions.output,
comments: false, // exclude all comments from output
ascii_only: true,
};
return args;
});
config.module
.rule("i18n")
.test(/.json$/)
.include.add(path.resolve(__dirname, "src/locales"))
.end()
.use("@intlify/vue-i18n-loader")
.loader("@intlify/vue-i18n-loader")
.end();
},
pluginOptions: {
webpackBundleAnalyzer: {
analyzerMode: process.env.VUE_APP_MODE === "production" ? "disabled" : "static",
openAnalyzer: false,
},
i18n: {
locale: "en",
fallbackLocale: "en",
localeDir: "locales",
enableInSFC: true,
},
},
configureWebpack: {
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
fallback: {
stream: require.resolve("stream-browserify"),
assert: require.resolve("assert/"),
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
os: require.resolve("os-browserify/browser"),
url: require.resolve("url/"),
},
},
plugins: [
new webpack.ContextReplacementPlugin(/date-fns[/\]/, new RegExp(`[/\\](en|de)[/\\]index.js$`)),
new CircularDependencyPlugin({
exclude: /a.js|node_modules/,
failOnError: true,
allowAsyncCycles: false,
cwd: process.cwd(),
}),
new ReplaceInFileWebpackPlugin([
{
dir: "dist/static/img",
files: ["sheet.json", "sheet_holiday.json"],
rules: [
{
search: '"image": "sheet.png"',
replace: '"image": "sheet.png?v=' + process.env.VUE_APP_VERSION + '"',
},
{
search: '"image": "characters.png"',
replace: '"image": "characters.png?v=' + process.env.VUE_APP_VERSION + '"',
},
{
search: '"image": "mall.png"',
replace: '"image": "mall.png?v=' + process.env.VUE_APP_VERSION + '"',
},
{
search: '"image": "sheet_holiday.png"',
replace: '"image": "sheet_holiday.png?v=' + process.env.VUE_APP_VERSION + '"',
},
],
},
]),
],
},
publicPath: "/",
outputDir: "dist",
runtimeCompiler: true,
assetsDir: "static",
productionSourceMap: false,
};
</code>
<code>const CircularDependencyPlugin = require("circular-dependency-plugin"); const ReplaceInFileWebpackPlugin = require("replace-in-file-webpack-plugin"); const webpack = require("webpack"); const path = require("path"); process.env.VUE_APP_VERSION = require("./package.json").version; module.exports = { chainWebpack: (config) => { config.optimization.minimizer("terser").tap((args) => { args[0].terserOptions.output = { ...args[0].terserOptions.output, comments: false, // exclude all comments from output ascii_only: true, }; return args; }); config.module .rule("i18n") .test(/.json$/) .include.add(path.resolve(__dirname, "src/locales")) .end() .use("@intlify/vue-i18n-loader") .loader("@intlify/vue-i18n-loader") .end(); }, pluginOptions: { webpackBundleAnalyzer: { analyzerMode: process.env.VUE_APP_MODE === "production" ? "disabled" : "static", openAnalyzer: false, }, i18n: { locale: "en", fallbackLocale: "en", localeDir: "locales", enableInSFC: true, }, }, configureWebpack: { resolve: { alias: { "@": path.resolve(__dirname, "src"), }, fallback: { stream: require.resolve("stream-browserify"), assert: require.resolve("assert/"), http: require.resolve("stream-http"), https: require.resolve("https-browserify"), os: require.resolve("os-browserify/browser"), url: require.resolve("url/"), }, }, plugins: [ new webpack.ContextReplacementPlugin(/date-fns[/\]/, new RegExp(`[/\\](en|de)[/\\]index.js$`)), new CircularDependencyPlugin({ exclude: /a.js|node_modules/, failOnError: true, allowAsyncCycles: false, cwd: process.cwd(), }), new ReplaceInFileWebpackPlugin([ { dir: "dist/static/img", files: ["sheet.json", "sheet_holiday.json"], rules: [ { search: '"image": "sheet.png"', replace: '"image": "sheet.png?v=' + process.env.VUE_APP_VERSION + '"', }, { search: '"image": "characters.png"', replace: '"image": "characters.png?v=' + process.env.VUE_APP_VERSION + '"', }, { search: '"image": "mall.png"', replace: '"image": "mall.png?v=' + process.env.VUE_APP_VERSION + '"', }, { search: '"image": "sheet_holiday.png"', replace: '"image": "sheet_holiday.png?v=' + process.env.VUE_APP_VERSION + '"', }, ], }, ]), ], }, publicPath: "/", outputDir: "dist", runtimeCompiler: true, assetsDir: "static", productionSourceMap: false, }; </code>
const CircularDependencyPlugin = require("circular-dependency-plugin");
const ReplaceInFileWebpackPlugin = require("replace-in-file-webpack-plugin");
const webpack = require("webpack");
const path = require("path");

process.env.VUE_APP_VERSION = require("./package.json").version;

module.exports = {
    chainWebpack: (config) => {
        config.optimization.minimizer("terser").tap((args) => {
            args[0].terserOptions.output = {
                ...args[0].terserOptions.output,
                comments: false, // exclude all comments from output
                ascii_only: true,
            };
            return args;
        });
        config.module
            .rule("i18n")
            .test(/.json$/)
            .include.add(path.resolve(__dirname, "src/locales"))
            .end()
            .use("@intlify/vue-i18n-loader")
            .loader("@intlify/vue-i18n-loader")
            .end();
    },
    pluginOptions: {
        webpackBundleAnalyzer: {
            analyzerMode: process.env.VUE_APP_MODE === "production" ? "disabled" : "static",
            openAnalyzer: false,
        },
        i18n: {
            locale: "en",
            fallbackLocale: "en",
            localeDir: "locales",
            enableInSFC: true,
        },
    },
    configureWebpack: {
        resolve: {
            alias: {
                "@": path.resolve(__dirname, "src"),
            },
            fallback: {
                stream: require.resolve("stream-browserify"),
                assert: require.resolve("assert/"),
                http: require.resolve("stream-http"),
                https: require.resolve("https-browserify"),
                os: require.resolve("os-browserify/browser"),
                url: require.resolve("url/"),
            },
        },
        plugins: [
            new webpack.ContextReplacementPlugin(/date-fns[/\]/, new RegExp(`[/\\](en|de)[/\\]index.js$`)),
            new CircularDependencyPlugin({
                exclude: /a.js|node_modules/,
                failOnError: true,
                allowAsyncCycles: false,
                cwd: process.cwd(),
            }),
            new ReplaceInFileWebpackPlugin([
                {
                    dir: "dist/static/img",
                    files: ["sheet.json", "sheet_holiday.json"],
                    rules: [
                        {
                            search: '"image": "sheet.png"',
                            replace: '"image": "sheet.png?v=' + process.env.VUE_APP_VERSION + '"',
                        },
                        {
                            search: '"image": "characters.png"',
                            replace: '"image": "characters.png?v=' + process.env.VUE_APP_VERSION + '"',
                        },
                        {
                            search: '"image": "mall.png"',
                            replace: '"image": "mall.png?v=' + process.env.VUE_APP_VERSION + '"',
                        },
                        {
                            search: '"image": "sheet_holiday.png"',
                            replace: '"image": "sheet_holiday.png?v=' + process.env.VUE_APP_VERSION + '"',
                        },
                    ],
                },
            ]),
        ],
    },
    publicPath: "/",
    outputDir: "dist",
    runtimeCompiler: true,
    assetsDir: "static",
    productionSourceMap: false,
};

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật