When I run ng build --prod, I get "Error: Cannot read property 'tapAsync' of undefined"

Viewed 2387

I get this strange error when I run ng build --prod

Error: Cannot read property 'tapAsync' of undefined

There is no stack trace and no other clues. However I have looked into the error log files and have found that the error happens in a file called ExternalModuleFactory.js here

    /**
     * @param {NormalModuleFactory} normalModuleFactory the normal module factory
     * @returns {void}
     */
    apply(normalModuleFactory) {
        const globalType = this.type;
    const factorized = normalModuleFactory.hooks.factorize;
    factorized.tapAsync(
            "ExternalModuleFactoryPlugin",
            (data, callback) => {
                const context = data.context;
                const dependency = data.dependencies[0];

Does anyone know what could be causing this, and/or at least how to debug this?

2 Answers

Got it working by uninstalling webpack 5.11 and installing npm install webpack@4

Related