Uncaught ReferenceError: exports is not defined

I am trying to upgrade Vue from 2.6.12 to 3.1.0 by following the migration section of the official site.
My application is a CakePHP ecommerce sit.
I have added the code to package.json and I have created webpack.config.js file and ran “npm install”.
But in browser console I am getting the error
“Uncaught ReferenceError: exports is not defined”
from file node_modules\vue\dist\vue.cjs.js
line
Object.defineProperty(exports, ‘__esModule’, { value: true });

I will be grateful if someone can help me out.

Thanks