简体   繁体   English

错误:插件/预设文件不允许导出对象,只能导出功能。 ReactJS

[英]Error: Plugin/Preset files are not allowed to export objects, only functions. ReactJS

I already tried different versions of babel and webpack but this issue still the same. 我已经尝试过不同版本的babel和webpack,但是此问题仍然相同。 It's not error in my webpack.config.js? 我的webpack.config.js不是错误吗? As you can see, the version of webpack there is low, maybe it's on the version of webpack if these are the errors? 如您所见,webpack的版本很低,如果出现这些错误,也许是在webpack的版本上?

I tried lower version of babel and still the same, I really can't figure this out. 我尝试了较低版本的babel,但仍保持不变,我真的无法弄清楚。 Already 24 hours problem and I stil can't fix this problem. 已经是24小时的问题,我仍然无法解决此问题。 I want to upgrade in ReactJS version 16. 我想在ReactJS版本16中升级。

webpack.config.js webpack.config.js

var path = require("path")
var webpack = require('webpack')
var BundleTracker = require('webpack-bundle-tracker')

// new WebpackDevServer(webpack(config), {

module.exports = {

  context: __dirname,
  entry: [
      'webpack-dev-server/client?http://localhost:3000',
      'webpack/hot/only-dev-server',
      './app/modules/common/index'
  ],

  output: {
      path: path.resolve('./app/static/bundles/'),
      filename: '[name]-[hash].js',
      publicPath: 'http://localhost:3000/app/static/bundles/',
       // Tell django to use this URL to load packages and not use STATIC_URL + bundle_name
  },

  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(), // don't reload if there is an error
    new BundleTracker({filename: './webpack-stats.json'}),
  ],

  module: {
    loaders: [
    { test: /\.css$/, loader: "style-loader!css-loader" },
      { test: /\.(jpe?g|png|gif|svg)$/i, loader: "file-loader?name=public/icons/[name].[ext]"},
      {
        test: /\.(js|jsx)$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
        query: {
            presets: ['es2015','react']
        }
    },
    ],
  },

  resolve: {
    modulesDirectories: ['node_modules', 'bower_components'],
    extensions: ['', '.js', '.jsx']
  }
}

Babel Configuration (.babelrc, package.json, cli command) Babel配置(.babelrc,package.json,cli命令)

package.json 的package.json

{
"devDependencies": {
"@babel/core": "^7.0.1",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"react-hot-loader": "^3.0.0-beta.6",
"webpack": "^1.9.8",
"webpack-bundle-tracker": "0.0.5",
"webpack-cli": "^2.1.3",
"webpack-dev-server": "^1.9.0",
"mobx-logger": "^0.5.0",
"mobx-react-devtools": "^4.2.11",
"file-loader": "^0.11.2"
"react": "^16.6.3",
"react-dom": "^16.6.3",
  },
}

.babelrc .babelrc

{
    "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
    ]
}

ERROR SCREENSHOT: 错误画面: 在此处输入图片说明

我现在明白了,我更改了webpack.config.js

query: { presets: [ '@babel/env', '@babel/react', ]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 出现“错误:插件/预设文件不允许导出对象,只能导出功能。” 来自 babel-preset-react-app/index.js - Getting "Error: Plugin/Preset files are not allowed to export objects, only functions." from babel-preset-react-app/index.js 使用 JEST 和 Vue.js 失败“插件/预设文件不允许导出对象,只能导出函数。” - Fail with JEST and Vue.js "Plugin/Preset files are not allowed to export objects, only functions." 反应错误:不允许插件/预设文件导出对象,仅导出功能 - error on react: Plugin/Preset files are not allowed to export objects, only functions Babel错误:插件/预设文件不允许导出对象,仅可导出功能 - Babel Error: Plugin/Preset files are not allowed to export objects, only functions 错误:插件/预设文件不允许导出对象,只能导出功能/ babel-preset-stage-0 - Error:Plugin /Preset files are not allowed to export objects,only functions/babel-preset-stage-0 Babel Plugin/Preset 文件不允许导出对象,只能导出函数 - Babel Plugin/Preset files are not allowed to export objects, only functions 用graphql开玩笑,“插件/预设文件不允许导出对象,只能导出功能” - Jest with graphql, “Plugin/Preset files are not allowed to export objects, only functions” gulp-babel插件错误:不允许插件/预设文件导出对象,仅导出功能 - Error in plugin gulp-babel: Plugin/Preset files are not allowed to export objects, only functions Babel-Loader Error Plugin/Preset 文件不允许导出对象,只能导出函数 - Babel-Loader Error Plugin/Preset files are not allowed to export objects, only functions “ npm start”抛出错误:不允许插件/预设文件导出对象,仅导出功能 - “npm start” throws Error: Plugin/Preset files are not allowed to export objects, only functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM