1

I'm trying to run yarn dev in my project and nothing happen, just display this error below:

[webpack-cli] TypeError: Cannot read property 'name' of undefined
    at new WebpackCLI (C:\Users\mikae\Desktop\phaser-game-multiplayer\game\node_modules\webpack-cli\lib\webpack-cli.js:18:22)
    at runCLI (C:\Users\mikae\Desktop\phaser-game-multiplayer\game\node_modules\webpack-cli\lib\bootstrap.js:7:21)
    at Object.<anonymous> (C:\Users\mikae\Desktop\phaser-game-multiplayer\game\node_modules\webpack-cli\bin\cli.js:25:5)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at runCli (C:\Users\mikae\Desktop\phaser-game-multiplayer\game\node_modules\webpack\bin\webpack.js:69:2)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

part of my webpack-cli.js where it's displaying the error

this.program = program;
this.program.name("webpack");
this.program.configureOutput({
        writeErr: this.logger.error,
        outputError: (str, write) =>
            write(
                `Error: ${this.utils.capitalizeFirstLetter(str.replace(/^error:/, "").trim())}`,
            ),
    });

What can I do? I just want to initialize my program.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Mikael
  • 329
  • 4
  • 10

2 Answers2

2

I encountered the same issue. When I checked it my webpack & webpack-cli versions didn't match.

This issue was during a setup of an older project that isn't mine.

I'm currently using using both webpack and webpack-cli at V4

Thomas H.
  • 21
  • 4
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/33207533) – Vojin Purić Nov 23 '22 at 08:00
1

I had the exact same error today within my own project. In the past the build was working but since I created a new repository from the sources and tried to build it from the new location the build was failing. Nothing helped but deleting the whole directory and re-clone the repository. Afterwards the build was completed successful.

MatthiasG
  • 4,434
  • 3
  • 27
  • 47