0
[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

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
DSham
  • 1
  • Does this answer your question? [Error \[ERR\_REQUIRE\_ESM\]: How to use es6 modules in node 12?](https://stackoverflow.com/questions/57169793/error-err-require-esm-how-to-use-es6-modules-in-node-12) – Hovercraft Full Of Eels Jul 23 '23 at 11:25
  • Does this answer your question? [Must use import to load ES module: ...\node_modules\got\dist\source\index.js](https://stackoverflow.com/questions/71215876/must-use-import-to-load-es-module-node-modules-got-dist-source-index-js) – Hovercraft Full Of Eels Jul 23 '23 at 11:26
  • Does this answer your question [webpack: "ERR_REQUIRE_ESM: Must use import to load ES Module" - But I AM using import!](https://stackoverflow.com/questions/65300985/webpack-err-require-esm-must-use-import-to-load-es-module-but-i-am-using) – Hovercraft Full Of Eels Jul 23 '23 at 11:27

0 Answers0