Summary of webpack v Error Reporting Solution of vue
- 2021-11-14 04:39:09
- OfStack
Xiaobai learns vue under 1, and then understands the related knowledge of webpack, and then installs various
cnpm is a domestic source, much faster than the international source. I don't know if cnpm is checked by myself.
cnpm install -g webpack
When 1 is installed successfully, I just want to see the version of webpack under 1
I was prompted to install webpack-cli, so install it
cnpm install -g webpack-cli
Wait 1 will be installed, and then look at 1 webpack-v to report the following error.
$ webpack -v
C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\lib\groups\resolveConfig.js: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\_v8-compile-cache@2.2.0@v8-compile-cache\v8-compile-cache.js:240:18)
at Module._compile (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_v8-compile-cache@2.2.0@v8-compile-cache\v8-compile-cache.js:184:36)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_v8-compile-cache@2.2.0@v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\lib\webpack-cli.js:14:32)
at Module._compile (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_v8-compile-cache@2.2.0@v8-compile-cache\v8-compile-cache.js:192:30)
Use npm list-depth=0-g to see which packages are installed.
I also printed various versions, but reported two mistakes. As a programmer for many years, I looked good and unhappy.
$ npm list --depth=0 -g
C:\Users\Administrator\AppData\Roaming\npm
+-- cnpm@6.1.1
+-- vue-cli@2.9.6
+-- webpack@4.19.0
`-- webpack-cli@4.2.0
npm ERR! error in C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_@webpack-cli_info@1.1.0@@webpack-cli: ENOENT: no such file or directory, open 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_@webpack-cli_info@1.1.0@@webpack-cli\package.json'
npm ERR! error in C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_@webpack-cli_serve@1.1.0@@webpack-cli: ENOENT: no such file or directory, open 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_@webpack-cli_serve@1.1.0@@webpack-cli\package.json'
So I looked at it carefully, If there is a lack of package. json file, then create a new one, and then report an error that cannot be read. Of course, the empty content cannot be read. If this file is found in other directories where there is no file, it will be copied to this level 1. After trying to check the version of each package for 1 time, it will not report an error, but webpack-v is still not easy to use. Reporting the above error, I think it may be webpack and webpack-cli versions do not correspond.
To view the version of the command:
cnpm view webpack versions
There are too many printed versions to put here. I see that my native version is 4.19. 0, and the latest version is 5.4. 0.
cnpm view webpack-cli versions
The latest webpack-cli is 4.2. 0.
Probably due to the asymmetry of the version.
Then I will uninstall webpack-cli and install it again.
cnpm uninstall weabpack-cli
Only up to date in 0.029 s was printed, which didn't seem to work very well. Using npm list -depth=0-g, it was found that webpack-cli @ 4.2. 0 was still there.
Then I looked at how to install the specified version of webpack-cli
Find an old 1 point version in the version just seen
cnpm install -g webpack-cli@3.3.10
After waiting for 1 to be installed successfully,
Look at npm list under 1-depth=0-g, printing is normal, and no error is reported.
$ npm list --depth=0 -g
C:\Users\Administrator\AppData\Roaming\npm
+-- cnpm@6.1.1
+-- vue-cli@2.9.6
+-- webpack@4.19.0
`-- webpack-cli@3.3.10
Then use webpack-v under 1, and no error will be reported, and it can be displayed normally
$ webpack -v
4.19.0
So far, climbing the pit is successful ~
A long time ago, I read many articles about different versions of node. js, and the versions of various tools managed by npm are also so pitted. I haven't learned yet, so I will learn to waste it. The road to programmers is very difficult! ! !