I have downloaded webpack-cli, but I still reported an error. Be deceived

I have downloaded webpack-cli, but I still reported an error. Blinded

D:\web\products\webpackTest2>webpack-cli -v
2.0.10

D:\web\products\webpackTest2>webpack-dev-server -v
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
module.js:540
    throw err;
    ^

Error: Cannot find module "webpack-cli/bin/config-yargs"
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\web\products\webpackTest2\node_modules\_webpack-dev-server@3.1.0@webpack-dev-server\bin\webpack-dev-server.js:65:1)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)

Mar.18,2021

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


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.


reference:

package.json version is as follows:

"webpack": "^5.17.0",
"webpack-cli": "^4.4.0",
"webpack-dev-server": "^3.11.2"

later on github issues find a solution

1, install
npm I webpack-cli @ webpack-cli/init
2, Adjust package.json

"scripts": {
    "start": "webpack-cli serve --mode development"
},

delete node\ _ modules


yarn add webpack webpack-cli -D


Edit package.json



"scripts":{
"start":"webpackserve"
}

yarn start

try not to use npm

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-1e44e38-59074.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-1e44e38-59074.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?