简体   繁体   English

“ npm start”抛出错误:不允许插件/预设文件导出对象,仅导出功能

[英]“npm start” throws Error: Plugin/Preset files are not allowed to export objects, only functions

I'm new to reactJS.I was following the steps given in one tutorial. 我是ReactJS的新手,我正在按照一个教程中给出的步骤进行操作。 When I type "npm start" I'm getting the following error: 当我输入“ npm start”时,出现以下错误:

ERROR in ./main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In C:\Users\user\Desktop\reactApp\node_modules\babel-preset-es2015\lib\index.js
    at createDescriptor (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-descriptors.js:178:11)
    at items.map (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-descriptors.js:109:50)
    at Array.map (native)
    at createDescriptors (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-descriptors.js:109:29)
    at createPresetDescriptors (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-descriptors.js:101:10)
    at passPerPreset (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-descriptors.js:58:96)
    at cachedFunction (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\caching.js:33:19)
    at presets.presets (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-descriptors.js:29:84)
    at mergeChainOpts (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-chain.js:315:26)
    at C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-chain.js:278:7
    at buildRootChain (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\config-chain.js:68:29)
    at loadPrivatePartialConfig (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\partial.js:57:55)
    at Object.loadPartialConfig (C:\Users\user\Desktop\reactApp\node_modules\@babel\core\lib\config\partial.js:82:18)
    at Object.<anonymous> (C:\Users\user\Desktop\reactApp\node_modules\babel-loader\lib\index.js:82:26)
    at next (native)
    at step (C:\Users\user\Desktop\reactApp\node_modules\babel-loader\lib\index.js:3:221)
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./main.js main[1]

Can someone please help me find the solution? 有人可以帮我找到解决方案吗?

package.json package.json

{
  "name": "npm",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": { "start": "webpack-dev-server" },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "webpack": "^4.17.1",
    "webpack-dev-server": "^3.1.6"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-react": "^7.0.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.0",
    "gulp-babel": "^8.0.0"
  }
}

webpack.config.js webpack.config.js

var config = {
  entry: "./main.js",
  output: { path: "/", filename: "index.js" },
  devServer: { inline: true, port: 8080 },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: "babel-loader",
        query: { presets: ["es2015", "react"] }
      }
    ]
  }
};
module.exports = config;
var config = {
  entry: "./main.js",
  output: { path: "/", filename: "index.js" },
  devServer: { inline: true, port: 8080 },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: "babel-loader",
        query: { presets: ["@babel/preset-env", "@babel/preset-react"] }
      }
    ]
  }
};
module.exports = config;

since its babel 7, it has to be namespaced, @babel ... 从babel 7开始,它必须命名为@babel ...

暂无
暂无

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

相关问题 反应错误:不允许插件/预设文件导出对象,仅导出功能 - 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 错误:插件/预设文件不允许导出对象,只能导出功能。 ReactJS - Error: Plugin/Preset files are not allowed to export objects, only functions. ReactJS 出现“错误:插件/预设文件不允许导出对象,只能导出功能。” 来自 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."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM