首页 > 解决方案 > Vue add i18n 返回 ERROR TypeError: Cannot read property 'minVersion' of undefined

问题描述

我尝试运行 vue clivue 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其他文件不会生成。

否则,我想尝试手动添加 i18n,npm install然后手动添加文件,但停留在编辑状态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

标签: javascriptvue.jsinternationalizationvue-i18n

解决方案


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

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

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


推荐阅读