SoFunction
Updated on 2025-04-03

Vue's webpack -V error reporting solution summary

Xiaobai learned vue, then learned about webpack, and then installed it in various ways

cnpm is a domestic source, which is much faster than international sources. If you don’t know, check it out by yourself.

cnpm install -g webpack

After a while the installation is successful, I want to see the version of webpack

I'm prompting me to install webpack-cli, so let's install it

cnpm install -g webpack-cli

After a while, the installation will be done. If you look at the webpack -v, you will report the following error.

$ webpack -v
C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\lib\groups\:105
        for await (const resolvedOption of finalizedConfigs) {
            ^^^^^
SyntaxError: Unexpected reserved word
    at NativeCompileCache._moduleCompile (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\[email protected]@v8-compile-cache\:240:18)
    at Module._compile (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\[email protected]@v8-compile-cache\:184:36)
    at ._extensions..js (:664:10)
    at  (:566:32)
    at tryModuleLoad (:506:12)
    at ._load (:498:3)
    at  (:597:17)
    at require (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\[email protected]@v8-compile-cache\:159:20)
    at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\lib\:14:32)
    at Module._compile (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\[email protected]@v8-compile-cache\:192:30)

Use npm list --depth=0 -g to see which packages are installed.
I also printed each version, but reported two errors. As a programmer for many years, I felt very unhappy.

$ npm list --depth=0 -g
C:\Users\Administrator\AppData\Roaming\npm
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

npm ERR! error in C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_@[email protected]@@webpack-cli: ENOENT: no such file or directory, open 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_@[email protected]@@webpack-cli\'
npm ERR! error in C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_@[email protected]@@webpack-cli: ENOENT: no such file or directory, open 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_@[email protected]@@webpack-cli\'

So I looked carefully and found that there was a missing file, so I created a new one, and then reported an error and could not be read. Of course, the empty content could not be read. I found this file in other directories with the path that showed no file, so I copied it to this level. I tried to check the versions of each package, and there was no error. However, webpack -v is still not easy to use, and the above error was reported. I think it might be a problem that webpack and webpack-cli versions do not correspond.

Check the version of the command:

cnpm view webpack versions

There are too many printed versions, so I won't put them here. When I saw that my version of this machine is 4.19.0, the latest version is 5.4.0.

cnpm view webpack-cli versions

The latest webpack-cli is 4.2.0.

Probably because of version asymmetry.

Then I will uninstall webpack-cli and install it.

cnpm uninstall weabpack-cli

I only printed up to date in 0.029s, which seemed not very useful. I used npm list --depth=0 -g to find that [email protected] is still there.

Then I checked how to install the specified version of webpack-cli

Find an older version I just saw

cnpm install -g [email protected]

After the installation is successful

Check the npm list --depth=0 -g, the printing is normal, and there is no error.

$ npm list --depth=0 -g
C:\Users\Administrator\AppData\Roaming\npm
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

Then use webpack -v again, and it will not report an error, it can be displayed normally

$ webpack -v
4.19.0

So far, the pit climbing is successful ~

I have read many articles with different versions of tricks a long time ago. The various tool versions that use npm to manage are also tricky. I have not learned it yet, so I have to learn it. The road to a programmer is very difficult! ! !

This is the end of this article about the summary of the solution of vue's webpack -v error reporting. For more related content of vue's webpack -v error reporting, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!