【问题标题】:Vue add i18n returns ERROR TypeError: Cannot read property 'minVersion' of undefinedVue add i18n 返回 ERROR TypeError: Cannot read property 'minVersion' of undefined
【发布时间】:2023-03-31 04:39:01
【问题描述】:

我尝试运行 vue cli vue add i18n 以使用 i18n 生成本地化到我的本地。出错了

Done in 37.95s.

    ✔  Successfully installed plugin: vue-cli-plugin-i18n
    
     ERROR  TypeError: Cannot read property 'minVersion' of undefined
    TypeError: Cannot read property 'minVersion' of undefined
        at module.exports.pkg (/mnt/disks/data_disks/teja/localised/forexsignals/node_modules/vue-cli-plugin-i18n/prompts.js:5:26)
        at invoke (/usr/local/lib/node_modules/@vue/cli/lib/invoke.js:74:25)
        at process._tickCallback (internal/process/next_tick.js:68:7)

i18n.js 和其他文件没有生成。

否则,我想尝试使用npm install 手动添加 i18n,然后手动添加文件,但在编辑vue.config.js 时卡住了,下面是我的vue.config.js 所示


    var PrerenderSpaPlugin = require('prerender-spa-plugin')
    var path = require('path')
    var Renderer = PrerenderSpaPlugin.PuppeteerRenderer;
    
    
    module.exports = {
      configureWebpack: config => {
        if (process.env.NODE_ENV !== 'production') return
    
        return {
          plugins: [
            new PrerenderSpaPlugin(
              {
                staticDir: path.resolve(__dirname, 'dist'),
                routes: ['/', '/join-free-channel'],
                renderer: new Renderer({
                  headless: true
                })
              }
            ),
          ]
        }
      }
    }

我已经为我的 vue 应用安装了预渲染,它更新了我的 vue.config.js 文件,但仍然不知道如何通过编辑 vue.config.js 为应用添加国际化

【问题讨论】:

    标签: javascript vue.js internationalization vue-i18n


    【解决方案1】:

    我最近遇到了这个问题,这是由于缺少 @vue/cli-shared-utils 依赖引起的。我不确定为什么安装 vue-cli 时没有安装它。

    这个问题的快速解决方案是安装这个依赖:npm i @vue/cli-shared-utils

    安装后,再次运行vue add i18n,它应该可以正常工作了。

    【讨论】:

      【解决方案2】:

      我遇到了类似的问题。我在vue add i18n 之后看到了这个错误,但我认为它们是相同的

      TypeError: Cannot read property 'split' of undefined
      

      所以,我只是删除了package-lock.json 文件,然后再次执行vue add i18n

      它对我有用。

      【讨论】:

        猜你喜欢
        • 2017-04-24
        • 2017-12-29
        • 2017-12-29
        • 2018-07-16
        • 1970-01-01
        • 1970-01-01
        • 2021-06-25
        • 2017-09-23
        • 2023-03-15
        相关资源
        最近更新 更多