SyntaxError: Unexpected token export when using lodash with Nuxt

SyntaxError: Unexpected token export when using lodash with Nuxt

这是我的现场演示回购 https://github.com/alechance/nuxt-lodash。我将 Nuxt 与 Vuetify + lodash-es 一起使用,当 运行 npm run dev 并重新加载我的页面时,我得到了 SyntaxError: Unexpected token exportexport default isArray;

lodash-es 库的导入文件未由 babel 转译。为了解决这个问题,Nuxt.js 提供了手动指定应通过 transpile 选项转译的文件的选项。

将以下代码添加到 nuxt.config.jsbuild 部分:

build: {
  transpile: [
    'lodash-es'
  ],
  // Other build options
}