This article is reproduced from: https://blog.csdn.net/jiang7701037/article/details/79403637
The CLI moved into a separate package: webpack-cli. Please install 'webpack-cli' in addition to webpack itself to use the CLI. -> When using npm: npm install webpack-cli -D -> When using yarn: yarn add webpack-cli -D
webpack4.0.1 installation problem, prompt:
The CLI moved into a separate package: webpack-cli. Please install 'webpack-cli' in addition to webpack itself to use the CLI. -> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D
solution:
1. The version number of webpack -v cannot come out
hint:
The CLI moved into a separate package: webpack-cli. Please install 'webpack-cli' in addition to webpack itself to use the CLI. -> When using npm: npm install webpack-cli -D -> When using yarn: yarn add webpack-cli -D
means that the CLI has been moved to a dedicated package webpack-cli. Please install webpack-cli in addition to webpack itself using cli. When using npm, use npm install webpack-cli -D to install. When using yarn, use yarn add webpack-cli -D to install.
Solution: Install webpack-cli globally npm install webpack-cli -g
to prompt the version number.
2. Install webpack-cli locally in the project directory -D
npm install webpack-cli -D
3. Install webpack locally in the project directory
npm install webpack -D
Fourth, the configuration file must be used: webpack.config.js
Do not use webpack commands, such as: webpack demo01.js bundle01.js, can no longer be executed.
5. Changes in the webpack.config.js file
The configuration in webpack.config.js no longer supports loaders under the module, you need to change the loaders to rules.
That is, as follows:
module: { rules: [ //For css files, perform corresponding loader processing { test: /\.css$/, loader: "style-loader!css-loader" } ] }