启动 vue js dev server 报错:.plugins[0] 可能只有二元组或三元组

Posted

技术标签:

【中文标题】启动 vue js dev server 报错:.plugins[0] 可能只有二元组或三元组【英文标题】:Starting vue js dev server gives eror: .plugins[0] may only be a two-tuple or three-tuple 【发布时间】:2019-07-02 23:41:23 【问题描述】:

我正在使用 Vue CLI 版本 3 在 Docker 容器内运行 Vue 应用程序。要启动开发服务器,我运行:

https://cli.vuejs.org/guide/cli-service.html

这会产生以下错误:

 ERROR  Failed to compile with 1 errors                                                                                                                                                          17:05:14

 error  in ./app/main.js

Module build failed (from ./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib/index.js):
Error: .plugins[0] may only be a two-tuple or three-tuple
    at assertPluginItem (/home/src/node_modules/@babel/core/lib/config/validation/option-assertions.js:235:13)
    at arr.forEach (/home/src/node_modules/@babel/core/lib/config/validation/option-assertions.js:222:30)
    at Array.forEach (<anonymous>)
    at assertPluginList (/home/src/node_modules/@babel/core/lib/config/validation/option-assertions.js:222:9)
    at Object.keys.forEach.key (/home/src/node_modules/@babel/core/lib/config/validation/options.js:107:5)
    at Array.forEach (<anonymous>)
    at validateNested (/home/src/node_modules/@babel/core/lib/config/validation/options.js:83:21)
    at validate (/home/src/node_modules/@babel/core/lib/config/validation/options.js:74:10)
    at file (/home/src/node_modules/@babel/core/lib/config/config-chain.js:174:34)
    at cachedFunction (/home/src/node_modules/@babel/core/lib/config/caching.js:33:19)
    at buildRootChain (/home/src/node_modules/@babel/core/lib/config/config-chain.js:120:36)
    at loadPrivatePartialConfig (/home/src/node_modules/@babel/core/lib/config/partial.js:85:55)
    at Object.loadPartialConfig (/home/src/node_modules/@babel/core/lib/config/partial.js:110:18)
    at Object.<anonymous> (/home/src/node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib/index.js:140:26)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/src/node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib/index.js:3:103)

 @ multi (webpack)-dev-server/client/index.js ./node_modules/@vue/cli-service/node_modules/webpack/hot/dev-server.js ./app/main.js

我怀疑有问题的代码如下,在我的.babelrc 文件中:

  "plugins": [
    ["transform-runtime", "transform-vue-jsx", "transform-regenerator", 
      "polyfill": false,
      "regenerator": true
    ]

有人可以建议我如何解决这个问题吗?谢谢!

【问题讨论】:

【参考方案1】:

您的[ 放错地方了。应该是

"plugins": [
  "transform-runtime", 
  "transform-vue-jsx", 
  ["transform-regenerator", 
    "polyfill": false,
    "regenerator": true
  ]
]

【讨论】:

以上是关于启动 vue js dev server 报错:.plugins[0] 可能只有二元组或三元组的主要内容,如果未能解决你的问题,请参考以下文章

Vue 项目: npm run dev b报错 “'webpack-dev-server' 不是内部或外部命令,也不是可运行的程序 或批处理文件。”

关于vue使用 npm run dev报错原因

vue项目,npm install后,npm run dev报错问题

npm run server报错

vue2.X版本vue-cli生成项目后运行失败,报错信息为getaddrinfo ENOTFOUND localhost

vue运行报错webpack-dev-server: command not found