webpack keeps asking if I want to install webpack-cli

Do you want to request a feature or report a bug?

I guess this is a bug

What is the current behavior?

I just installed Webpack, using:
npm install -g webpack

I then run webpack from the command line without parameters:
webpack

Each time I do this, it asks me if I want to install the webpack-cli
Would you like to install webpack-cli? (That will run npm install -D webpack-cli) (yes/NO)

When I reploy with n or just newline, and then run webpack again, it asks me again if I want to install webpack-cli. When I hit y, it seems to set out to install webpack-cli. It gives me these messages:

npm WARN deprecated babel-preset-es2015@6.24.1: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
react-and-webpack@1.0.0 E:\Decideware\trials\React\ReactAndWebpack\proj
`– webpack-cli@2.1.2

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.1.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {“os”:”darwin”,”arch”:”any”} (current: {“os”:”win32″,”arch”:”x64″})
npm WARN react-and-webpack@1.0.0 No description
npm WARN react-and-webpack@1.0.0 No repository field.
{ Error: Cannot find module ‘webpack-cli’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at runCommand.then.result (C:\Users\mperdeck\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:62:14)
at process._tickCallback (internal/process/next_tick.js:109:7) code: ‘MODULE_NOT_FOUND’ }

When I then run webpack again from the command line (again without parameters), it asks me again if I want to install-cli.

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

That it remembers that I don’t want webpack-cli and doesn’t ask me again. Or that it installs webpack-cli when I reply y and then stops asking me if I want to install webpack-cli again.

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.

node: 6.11.5
webpack: just installed
OS: windows 10

Author: Fantashit

22 thoughts on “webpack keeps asking if I want to install webpack-cli

  1. Have you tried installing webpack locally instead of globally? You might have an old version of webpack globally and the webpack-cli may not know where to pull the right version from. I would try wiping the global install, installing both locally and attempting to run again.

  2. Thanks for you response. However, your suggestion doesn’t seem to be working.

    I cleared the cache using
    npm cache clean –force

    Installed webpack and webpack-cli locally
    npm install webpack
    npm install webpack-cli

    Ran webpack from the command line, with the same result. It still keeps asking if I want to install webpack-cli.

    Full session:

    C:\Dev\trial\React\ReactAndWebpack\proj>npm cache clean –force
    npm WARN using –force I sure hope you know what you are doing.

    C:\Dev\trial\React\ReactAndWebpack\proj>npm install webpack
    npm WARN react-and-webpack@1.0.0 No description
    npm WARN react-and-webpack@1.0.0 No repository field.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {“os”:”darwin”,”arch”:”any”} (current: {“os”:”win32″,”arch”:”x64″})

    • webpack@4.7.0
      updated 1 package in 14.004s

    C:\Dev\trial\React\ReactAndWebpack\proj>webpack
    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)
    It needs to be installed alongside webpack to use the CLI

    C:\Dev\trial\React\ReactAndWebpack\proj>webpack
    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)
    It needs to be installed alongside webpack to use the CLI

    C:\Dev\trial\React\ReactAndWebpack\proj>npm install webpack-cli
    npm WARN deprecated babel-preset-es2015@6.24.1: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
    npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
    npm WARN react-and-webpack@1.0.0 No description
    npm WARN react-and-webpack@1.0.0 No repository field.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {“os”:”darwin”,”arch”:”any”} (current: {“os”:”win32″,”arch”:”x64″})

    • webpack-cli@2.1.2
      updated 1 package in 22.393s

    C:\Dev\trial\React\ReactAndWebpack\proj>webpack
    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)
    It needs to be installed alongside webpack to use the CLI

  3. I am having the exact same issue. Is there any fix? It just keeps prompting me to install web-pack CLI even when i’ve installed like 5000 times.

  4. when I enter webpack -v in command line, I have always the same message
    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)

  5. If you run webpack in console (webpack) and it is output question about isntall webpack-cli it is mean you have global installation.

  6. It seems that webpack-cli used to be in the webpack package , but now it is moved into a separate package. So after I installed webpack-cli globally, my issue, likes yours, was fixed.
    Besides, you may get the following warning:
    WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment. You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/
    So, you had better set the ‘mode’ option in webpack.config.js.

  7. I installed webpack-command globally and than webpack globally again (without doing anything else),
    It seems to work fine now

  8. I went through this problem today, I decided as follows.
    npm uninstall –save-dev ‘name of all dependencies related to the webpack, including itself’
    then I uninstalled it globally
    npm uninstall -g webpack webpack-cli (I had already installed the cli, anyway it was not catching).
    I set it up again
    npm install -g webpack webpack-cli
    webpack –help got it 🙂 hope it works with you too
    (do not forget to install in your project with –save-dev)

  9. I encountered the same problem above, so I re-installed webpack and webpack-cli globally. Then another error occurs:

    >> webpack
    
    /PATH/TO/PROJECT/node_modules/webpack-cli/bin/cli.js:244
                                    throw err;
                                    ^
    
    Error: Cannot find module 'webpack'
        at Function.Module._resolveFilename (module.js:469:15)
        at Function.Module._load (module.js:417:25)
        at Module.require (module.js:497:17)
        at require (/PATH/TO/PROJECT/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
        at Object.<anonymous> (/PATH/TO/PROJECT/node_modules/webpack-cli/bin/convert-argv.js:7:42)
        at Module._compile (/PATH/TO/PROJECT/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
        at Object.Module._extensions..js (module.js:579:10)
        at Module.load (module.js:487:32)
        at tryModuleLoad (module.js:446:12)
        at Function.Module._load (module.js:438:3)
        at Module.require (module.js:497:17)
        at require (internal/module.js:20:19)
        at yargs.parse.err (/PATH/TO/PROJECT/node_modules/webpack-cli/bin/cli.js:241:14)
        at Object.parse (/PATH/TO/PROJECT/node_modules/yargs/yargs.js:563:18)
        at /PATH/TO/PROJECT/node_modules/webpack-cli/bin/cli.js:219:8
        at Object.<anonymous> (/PATH/TO/PROJECT/node_modules/webpack-cli/bin/cli.js:530:3)
        at Module._compile (module.js:570:32)
        at Object.Module._extensions..js (module.js:579:10)
        at Module.load (module.js:487:32)
        at tryModuleLoad (module.js:446:12)
        at Function.Module._load (module.js:438:3)
        at Module.require (module.js:497:17)
        at require (internal/module.js:20:19)
        at module.exports.filename (/usr/local/lib/node_modules/webpack-cli/node_modules/import-local/index.js:16:66)
        at /usr/local/lib/node_modules/webpack-cli/bin/cli.js:13:6
        at Object.<anonymous> (/usr/local/lib/node_modules/webpack-cli/bin/cli.js:530:3)
        at Module._compile (module.js:570:32)
        at Object.Module._extensions..js (module.js:579:10)
        at Module.load (module.js:487:32)
        at tryModuleLoad (module.js:446:12)
    

    versions:

    • webpack: 4.16.1
    • webpack-cli: 3.1.0

    Does anyone have any ideas? Thanks.


    I just figured out my problem. See this stackoverflow answer.
    I hope this helps 🙂

  10. i have got
    One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:

    One CLI needs to be installed alongside webpack to use the CLI.

    this problem

  11. What is the solution of this problem ?
    please help me out
    /Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/bin/cli.js:244
    throw err;
    ^

    ReferenceError: nodeExternals is not defined
    at Object. (/Users/mr.Singla/projects/mernStack/webpack.config.server.js:10:20)
    at Module._compile (/Users/mr.Singla/projects/mernStack/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (/Users/mr.Singla/projects/mernStack/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at WEBPACK_OPTIONS (/Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/bin/convert-argv.js:133:13)
    at requireConfig (/Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/bin/convert-argv.js:135:6)
    at /Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/bin/convert-argv.js:142:17
    at Array.forEach ()
    at module.exports (/Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/bin/convert-argv.js:140:15)
    at yargs.parse (/Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/bin/cli.js:241:39)
    at Object.parse (/Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/node_modules/yargs/yargs.js:563:18)
    at /Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/bin/cli.js:219:8
    at Object. (/Users/mr.Singla/projects/mernStack/node_modules/webpack-cli/bin/cli.js:530:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object. (/Users/mr.Singla/projects/mernStack/node_modules/webpack/bin/webpack.js:165:2)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

  12. this error is happening on my jenkins server only and causing my pipeline to fail, not sure how to proceed

    > webpack --config webpack/webpack.qa.babel.js
    
    One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
     - webpack-cli (https://github.com/webpack/webpack-cli)
       The original webpack full-featured CLI.
    We will use "npm" to install the CLI via "npm install -D".
    Do you want to install 'webpack-cli' (yes/no): 
    
  13. If you have webpack-cli and webpack installed that message shoudn’t appear.

    Webpack should be atleast 4.x.x to throw that message (not 100%% sure if v3 does it too).

    In the case of local enviroment: check which libraries have you installed globally: npm ls -g --depth=0 or try to find it with which webpack.

    In the case of CI: check that you actually install the devDependencies if you have both webpack-cli and webpack in your package.json. In yarn for instance, if your NODE_ENV is set to production your yarn will not install devDependencies. In npm check that you are installing without --prod option.

  14. echo "yes" | webpack
    echo yes will buffer the stdin to npm to get around it not supporting non-interactive installs

  15. What should I do? I feel very tired

    ➜  temp20190217 webpack
    One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
     - webpack-cli (https://github.com/webpack/webpack-cli)
       The original webpack full-featured CLI.
    We will use "npm" to install the CLI via "npm install -D".
    Do you want to install 'webpack-cli' (yes/no): 
    

    I always catch this message, even after I do like instruction, error still happen.

  16. @evilebottnawi

    As i describe above you need write own scripts to run webpack.

    Can you point me to some example code (e.g. in CRA) that shows what a script has to do to be able to run webpack w/o webpack-cli?

  17. You may face this problem if you additionally have the yarn package manager installed.

    This is because the webpack-cli binary might be linked to npm’s global node_modules directory, but when running detects the yarn and automatically runs yarn global add and installs the package to the yarn’s global node_modules directory. And then tries to find the newly installed package in the npm’s globals, unsuccessfully.

    You need to uninstall all the webpack modules installed globally by npm and reinstall them globally by yarn.

    Or simply install missing webpack modules using the npm by yourself, like:

    $ npm install -g @webpack-cli/init

    Just keep in mind that if you have yarn installed, webpack tries to detect and use it for installing missing packages. But then, by some reason, tries to find them in npm’s global node_modules directory.

  18. I had the same issue today. I just installed webpack and webpack-cli again globaly and it fixed the problem.
    npm i -g webpack webpack-cli

Comments are closed.