W
W
Wasya UK2018-10-18 13:41:56
JavaScript
Wasya UK, 2018-10-18 13:41:56

Webpack require is not a function?

Why, when connecting koa-body After processing with webpack, I get an error when starting the server
import bodyParser from "koa-body";

var crypto = require('crypto');
             ^

TypeError: require is not a function

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

webpack
rules: [
      {
        test: /\.(m?js|jsx)$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: 'babel-loader'
        }
      }
    ]

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question