[webpack-cli] Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\Web Development\Laravel\shopping-cart\webpack.mix.js
require() of ES modules is not supported.
require() of D:\Web Development\Laravel\shopping-cart\webpack.mix.js from D:\Web Development\Laravel\shopping-cart\node_modules\laravel-mix\setup\webpack.config.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename webpack.mix.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from D:\Web Development\Laravel\shopping-cart\package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at module.exports (D:\Web Development\Laravel\shopping-cart\node_modules\laravel-mix\setup\webpack.config.js:11:5)
at loadConfigByPath (D:\Web Development\Laravel\shopping-cart\node_modules\webpack-cli\lib\webpack-cli.js:1439:37)
at async Promise.all (index 0)
at async WebpackCLI.loadConfig (D:\Web Development\Laravel\shopping-cart\node_modules\webpack-cli\lib\webpack-cli.js:1454:35)
at async WebpackCLI.createCompiler (D:\Web Development\Laravel\shopping-cart\node_modules\webpack-cli\lib\webpack-cli.js:1785:22) {
code: 'ERR_REQUIRE_ESM'
}
I am trying to install Laravel breeze by using the steps below:
composer require laravel/breeze --dev
php artisan breeze:install
npm install
npm run dev
On npm run dev
, it occurred the above error and I could not figure out the problem even I found out the documentation of webpack.
I am trying to follow step by step documentation about Laravel breeze but not sure why there occurred a problem error