Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The CLI moved into a separate package: webpack-cli. What is wrong in my procedure?

When I run ./node_modules/.bin/webpack-dev-server to build, this error happens

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:559
    throw err;
    ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Module.require (module.js:606:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/xxx/Downloads/react_app/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)

therefore I run npm install webpack-cli -D command and I run the command again but zsh: no such file or directory: ./node_modules/.bin/webpack-dev-server error happens.I followed procedure to build react.js so I think my building procedure has no error.So what should I do to fix this?Does this error cause difference of libraries version?How should I fix this? My webpack.config.js is

var publidDir = __dirname + '/public';
module.exports = {
  entry: [
    './src/index.js'
  ],
  output: {
    path: publidDir,
    publicPath: '/',
    filename: 'bundle.js'
  },
  module: {
    loaders: [{
      exclude: /node_modules/,
      loader: 'babel-loader',
      query: {
        presets: ['react', 'es2015']
      }
    }]
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  devServer: {
    historyApiFallback: true,
    contentBase: publidDir
  }
};
like image 793
user9170657 Avatar asked Dec 16 '25 18:12

user9170657


1 Answers

I was having the same problem after update some dependencies. Check the webpack-dev-server version, I had 3.1.3 and I was getting same error as you. This what I have right now:

"webpack": "^3.10.0",
"webpack-dev-server": "2.9.7"
like image 83
Franklin Castillo Avatar answered Dec 19 '25 15:12

Franklin Castillo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!