How to install webpack-cli?

12,456

Solution 1

It worked for me by installing below modules:

npm i -g webpack-cli

npm install --save-dev webpack

npm install --save-dev webpack-dev-server

Solution 2

This is happening because while webpack-cli might be installed globally, it is not installed in your current project, and somehow the project isn't capable of using the globally-installed version.

I fixed this by running npm install webpack-cli in the relevant project directory.

Share:
12,456

Related videos on Youtube

mircealungu
Author by

mircealungu

programmer among athletes. athlete between programmers. smalltalker between pythonists.

Updated on September 15, 2022

Comments

  • mircealungu
    mircealungu over 1 year

    I have installed webpack 4.5.0.

    When I try to run webpack, it complains that it wants webpack-cli.

    If I run npm install webpack-cli I get the following error:

    The CLI moved into a separate package: webpack-cli
    Would you like to install webpack-cli? (That will run npm install -D webpack-cli) (yes/NO)yes
    npm WARN deprecated [email protected]: Package no longer supported. Contact [email protected] for more info.
    npm WARN [email protected] requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
    
    + [email protected]
    updated 1 package in 14.175s
    { Error: Cannot find module 'webpack-cli'
        at Function.Module._resolveFilename (module.js:543:15)
        at Function.Module._load (module.js:470:25)
        at Module.require (module.js:593:17)
        at require (internal/module.js:11:18)
        at runCommand.then.result (/usr/local/lib/node_modules/webpack/bin/webpack.js:62:14)
        at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7) code: 'MODULE_NOT_FOUND' }
    

    Anybody has seen this and fixed it somehow?

    • Spock
      Spock almost 6 years
      arggh just came here to say that's what solved it for me