Topic: Error: Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

Support_Net15 free asked 3 years ago


After importing MDB Pro into my project by following the documentation on this link


Knowing that I am on symfony 5 and I use Webpack Encore, the version of node I use 12.18.3 and npm -v 14.8, the build run fine without error, on the other hand on all browsers, I have the following error

Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
    at Object.<anonymous> (mdb.js:9192)
    at Object.<anonymous> (mdb.js:9195)
    at n (mdb.js:36)
    at Module.<anonymous> (mdb.js:20789)
    at n (mdb.js:36)
    at Object.<anonymous> (mdb.js:9091)
    at n (mdb.js:36)
    at mdb.js:70
    at Object.<anonymous> (mdb.js:26)
    at Object../node_modules/mdbootstrap-pro/js/mdb.js (vendors~appGlobalFrontend.js:2)

I did some research on the forum and I couldn't find a solution to my problem, please tell me what to do to resolve this problem.

My configuration files:


@import "~mdbootstrap-pro/css/bootstrap.min.css";
@import "~@fortawesome/fontawesome-free/css/all.css";
@import '~mdbootstrap-pro/css/mdb.min.css';


import $ from 'mdbootstrap-pro/js/jquery';
import 'mdbootstrap-pro/js/popper'
import 'mdbootstrap-pro/js/bootstrap';
import * as mdb from 'mdbootstrap-pro/js/mdb'


import '../scss/appGlobalFrontend.scss';


var Encore = require('@symfony/webpack-encore');
const CopyPlugin = require('copy-webpack-plugin');
const TerserJsPlugin = require('terser-webpack-plugin');

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
    Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');

    // directory where compiled assets will be stored
    // public path used by the web server to access the output path

     * Add 1 entry for each "page" of your app
     * (including one that's included on every page - e.g. "app")
     * Each entry will result in one JavaScript file (e.g. app.js)
     * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
    .addEntry('appGlobalBackend', './assets/js/appGlobalBackend.js',
            preload: true,
            defer: true,
            minimizer: true
    .addEntry('appGlobalFrontend', './assets/js/appGlobalFrontend.js',
            preload: true,
            defer: true,
            minimizer: true

    // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.

    // will require an extra script tag for runtime.js
    // but, you probably want this, unless you're building a single-page app

     * Enable & configure other features below. For a full
     * list of features, see:
    // enables hashed filenames (e.g. app.abc123.css)

    // enables @babel/preset-env polyfills
    .configureBabelPresetEnv((config) => {
        config.useBuiltIns = 'usage';
        config.corejs = 3;

    // enables Sass/SCSS support
    .enableSassLoader(function (sassOptions){}, {

    // Generate icons for different mobile
        new CopyPlugin({
            patterns: [
                {from: './assets/media/icons', to: 'icons'},
                {from: './assets/media/logo', to: 'logo'},
                {from: './assets/media/images', to: 'images'},

    // uncomment if you're having problems with a jQuery plugin
        $: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery',

    // Configure terser-webpack-plugin
    .configureTerserPlugin((options) => {
        options.cache = true;
        options.parallel = true;
        options.terserOptions = {
            output: {
                comments: false,

    // uncomment if you use API Platform Admin (composer req api-admin)
    //.addEntry('admin', './assets/js/admin.js')

const webpackConfig = Encore.getWebpackConfig();
// Add the new TerserSsPlugin object
webpackConfig.plugins.push(new TerserJsPlugin());

module.exports = webpackConfig;


Grzegorz Bujański staff commented 3 years ago

Have you tried to import mdb.min.js replacement modules? Check out this thread: it can help you.

mcwnuq free answered 2 years ago

Hi, have you fixed this? Just upgraded from 4.7.7 to 4.19.2 and have this issue.

Mikołaj Smoleński staff commented 2 years ago

We still don't officially support Symfony.

Keep coding, Mikołaj from MDB

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.19.1
  • Device: Any
  • Browser: Chrome, Firefox
  • OS: Ubuntu 20
  • Provided sample code: No
  • Provided link: Yes