Run the webpack command and keep prompting to install webpack-cli

after running the npm install webpack-cli-D command at the prompt, package.json shows the existing webpack-cli, and then runs the webpack command again.

Mar.04,2021

recently I am also learning the latest version of webpack. This problem also bothered me for a while at first, but later found out that it was already written clearly in the guide of the original document.
that is to use the npx command.

none of the answers from upstairs actually solved the problem at all.

webpack4's latest documentation, it is recommended that each project use a separate webpack, that is, a partial installation. The package.json in such a project can manage the dependent environment package. Global installation of webpack and webpack-cli again is global and does not have the effect of local installation.

During the partial installation of

, the executable files of these executable packages, that is, cmd files, are all in the node_module/.bin directory of the project, and the npx command is to automatically go to this directory to find the execution files.

so, partially install the project's own webpack and webpack-cli, and execute, just a few commands:

npm init-y
npm install webpack- D
npm install webpack-cli-D

after writing the webpack configuration file, package the command:
npx webpack

of course, it is also possible to use a global webpack. However, if the project is copied to someone else's computer, there is no guarantee that webpack is a unified version. No, no, no.


when you have the same problem,
npm I webpack-cli-D is done, and you still need to install npm I webpack-cli-g
globally before using webpack.
if you report an error during the installation of webpack-cli, you may also need to configure the environment variable path of node


.

it needs to be installed alongside webpack to use the CLI

webpack-cli needs to be installed at the same time as webpack to take effect. Remember! Install

at the same time

yarn add webpack-cli webpack- D


if you want to hold a command, you need to install one globally.

otherwise, complete the path. / node_modules/webpack

if you remember correctly, you will complete the path anyway, because you-D is installed under the node_modules of the current project. You need to tell him where to find this order

otherwise he would have gone to the whole world to look for it. However, if the global situation cannot be found, an error will be reported

.

encountered the same problem. I don't know if you also use webpack4?.
my solution is to add the configuration to the config configuration file: mode: 'development' or mode:' production'

module.exports={
    //
    mode: 'development',
    devServer: {
        //
        
    } 
}

mode is a new configuration item for webpack4.
you can try. The
command line with arguments-- mode development or-- mode production should also work.
or return to the old version


then install one? We'll know when the system is finished.


I just encountered this problem, but I partially installed a webpack-cli and solved


I didn't directly-g ok


npm install webpack-cli-g / / global installation
webpack- v / see version
webpack / / packaged into

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37d2c-2c0d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37d2c-2c0d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?