Rails webpacker + vue给出了未捕获的错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js):

时间:2020-09-23 04:02:59

标签: ruby-on-rails babeljs webpack-dev-server webpacker vue-loader

当我在rails上安装webpacker + vue时,出现了此错误,我安装了它想要的一些依赖项,即package.json:

{
  "dependencies": {
    "@rails/webpacker": "4.3.0",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "vue": "^2.6.12",
    "vue-loader": "^15.9.3",
    "vue-template-compiler": "^2.6.12"
  },
  "devDependencies": {
    "webpack-dev-server": "^3.11.0"
  }
}

我正在布局中使用此标签:

    <%= javascript_pack_tag 'hello_vue' %>
    <%= stylesheet_pack_tag 'hello_vue' %>

这是hello_vue.js:

import Vue from 'vue'
import App from '../app.vue'

document.addEventListener('DOMContentLoaded', () => {
  const app = new Vue({
    render: h => h(App)
  }).$mount()
  document.body.appendChild(app.$el)
})

我的日志中出现此错误:

bootstrap:83 Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In /mnt/c/Users/smond/dev/mandala/node_modules/babel-preset-react/lib/index.js

我还没有创建任何webpack.config.js,我是否必须创建一个webpack.config.js文件,我不明白我应该在useMemo文件中添加什么

0 个答案:

没有答案