Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'call' of undefined at __webpack_require__ #2231

Closed
1 of 2 tasks
rbuetzer opened this issue Aug 27, 2019 · 4 comments
Closed
1 of 2 tasks

Cannot read property 'call' of undefined at __webpack_require__ #2231

rbuetzer opened this issue Aug 27, 2019 · 4 comments

Comments

@rbuetzer
Copy link

  • Operating System: Windows 10
  • Node Version: n/a
  • NPM Version: Yarn 1.16.0
  • webpack Version: 4.12.0
  • webpack-dev-server Version: 3.3.1
  • Browser: Chrome 76, Firefox 68
  • This is a bug
  • This is a modification request

webpack.config.js

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    entry: {
        app: './src/index.tsx',
    },
    output: {
        filename: 'js/[name].bundle.js',
        path: __dirname + '/dist',
    },
    devtool: 'source-map',
    resolve: {
        extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                loader: 'ts-loader',
            },
            {
                test: /\.less$/,
                exclude: '/node_modules/',
                use: [
                    {
                        loader: MiniCssExtractPlugin.loader,
                        options: {
                            publicPath: '../',
                            hmr: process.env.NODE_ENV === 'development',
                        },
                    },
                    {
                        loader: 'css-loader',
                        options: {
                            localIdentName: '[local]--[hash:5]',
                            sourceMap: true,
                        },
                    },
                    {
                        loader: 'less-loader',
                        options: {
                            sourceMap: true,
                        },
                    },
                ],
            },
            {
                test: /\.html$/,
                use: 'raw-loader',
            },
            {
                test: /\.jpe?g$|\.gif$|\.png$/i,
                loader: 'file-loader?name=assets/img/[name].[ext]',
            },
            {
                test: /\.woff2?$|\.ttf$|\.eot$|\.svg$|\.mp3$/,
                use: 'file-loader?name=assets/[name].[ext]',
            },
        ],
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: 'framework/style/style.css',
        }),
        new HtmlWebpackPlugin({
            template: 'src/index.html',
            filename: 'index.html',
        }),
        new CopyWebpackPlugin([
            './src/manifest.json',
            './src/settings.js',
            './src/favicon.ico',
            { from: '**/app_icon*.png', flatten: true },
        ]),
    ],
    optimization: {
        splitChunks: {
            cacheGroups: {
                commons: { test: /[\\/]node_modules[\\/]/, name: 'vendors', chunks: 'all' },
            },
        },
    },
};

Expected Behavior

When I run my project with webpack-dev-server, I get no runtime errors

Actual Behavior

When I run my project with webpack-dev-server I get the following runtime error:

Cannot read property 'call' of undefined at __webpack_require__

Workarounds

  • The app runs fine with webpack-dev-server v3.3.0
  • The app runs fine, when the entry property of the webpack config is an array instead of a string:
entry: {
    app: ['./src/index.tsx']
},
@rbuetzer
Copy link
Author

rbuetzer commented Aug 27, 2019

Possibly related: webpack/webpack#6094

@alexander-akait
Copy link
Member

Please create minimum reproducible test repo otherwise issue was closed

@rbuetzer
Copy link
Author

As said in b31cbaa#commitcomment-34848401, I can't create a test repo. I understand that you won't investigate the issue in this case and therefore close this issue.

@restuwahyu13
Copy link

restuwahyu13 commented Sep 14, 2020

follow step by step this solution for fix this problem, working with me using webpack 4

1.STEP ONE
output: {
library: '[name]',
umdNamedDefine: false
}

optimization: {
concatenateModules: false,
providedExports: false,
usedExports: false
}

  1. STEP TWO
    remove symlink and caheWithContenxt

  2. STEP THREE
    remove react hot module or disable this for production

  3. STEP FOUR
    remove old project name in heroku, after remove old project create new project name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants