Как я могу решить эту ошибку веб-пакета или babel? - PullRequest
0 голосов
/ 13 декабря 2018

Как я могу устранить эту ошибку в веб-пакете или вавилонском сообщении?

Я не могу понять, что мне сказал терминал!

Может быть, это значит о webpack.config.js, но я не могу понять это.

Что мне делать?

Это код ошибки.

gotaegeon-ui-MacBook-Pro:JUMP-FrontEnd gotaegeon$ ./node_modules/.bin/webpack
    Hash: 7c305f3386d8f5ab3ba9
    Version: webpack 4.27.1
    Time: 574ms
    Built at: 12/14/2018 12:11:17 AM
    1 asset
    Entrypoint main = bundle.js
    [0] ./src/index.js 3.11 KiB {0} [built] [failed] [1 error]

    ERROR in ./src/index.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 /Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-preset-es2015/lib/index.js
    at createDescriptor (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-descriptors.js:178:11)
    at items.map (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPresetDescriptors (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
    at passPerPreset (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-descriptors.js:58:96)
    at cachedFunction (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/caching.js:33:19)
    at presets.presets (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-descriptors.js:29:84)
    at mergeChainOpts (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-chain.js:315:26)
    at /Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-chain.js:278:7
    at buildRootChain (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/config-chain.js:68:29)
    at loadPrivatePartialConfig (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/partial.js:85:55)
    at Object.loadPartialConfig (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/@babel/core/lib/config/partial.js:110:18)
    at Object.<anonymous> (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-loader/lib/index.js:140:26)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-loader/lib/index.js:3:103)
    at _next (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-loader/lib/index.js:5:194)
    at /Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-loader/lib/index.js:5:364
    at new Promise (<anonymous>)
    at Object.<anonymous> (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-loader/lib/index.js:5:97)
    at Object._loader (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-loader/lib/index.js:220:18)
    at Object.loader (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-loader/lib/index.js:56:18)
    at Object.<anonymous> (/Users/gotaegeon/Documents/gtg7784/Programming/JUMP-FrontEnd/node_modules/babel-loader/lib/index.js:51:12)

, это webpack.config.js

module.exports = {
    mode: 'production',
    entry: './src/index.js',

    output: {
        path: __dirname + '/public',
        filename: 'bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/,
                options: {
                    cacheDirectory: true,
                    presets: ['es2015', 'react']
                },
            }
        ]
    }
};

и это.babelrc

{
    "presets": ["es2015"]
}

1 Ответ

0 голосов
/ 13 декабря 2018

Я надеюсь, что это работает для вас

.babelrc

{
    "presets": ["react", "env"],
}

webpack.config.js

module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
    path: __dirname + '/public',
    filename: 'bundle.js'
},
module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
    ]
}
};
...