Okta React SDK failing with webpack 5

Hi,

I am using okta react SDK @okta/okta-react@3.0.8 with webpack 5.1.3 and webpack-cli 4.1.0.

Now now I am getting the error "Uncaught (in promise) ReferenceError: require is not defined at Module…/node_modules/@okta/okta-react/src/index.js "

Please help.

Regards,
Sachin Raj

try to create an issue in their GitHub repo for okta-react

@sachinraj Would you be able to email developers@okta.com with the details including your webpack config ?

I saw the same issues. I reverted to webpack 4.44.2 and it works fine.
My webpack.config.js is pretty standard:

const path = require("path");
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
  mode: "development",
  entry: "./src/index.js",
  devtool: "inline-source-map",
  plugins: [
  ],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /(node_modules|bower_components)/,
        loader: "babel-loader",
        options: { presets: ["@babel/env"] }
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      }
    ]
  },
  output: {
    path: path.resolve(__dirname, "dist"),    
    filename: "bundle.js",
    publicPath: "/"
  },
  devServer: {
    contentBase: path.join(__dirname, "public"),
    port: 3000,
    publicPath: "/",
    historyApiFallback: true
  }
};

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.