New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack keeps asking if I want to install webpack-cli #7197

Closed
mperdeck opened this Issue May 4, 2018 · 23 comments

Comments

Projects
None yet
@mperdeck

mperdeck commented May 4, 2018

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

@TheLarkInn

This comment has been minimized.

Member

TheLarkInn commented May 4, 2018

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.

@TheLarkInn TheLarkInn closed this May 4, 2018

@mperdeck

This comment has been minimized.

mperdeck commented May 5, 2018

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

@nataliaperina

This comment has been minimized.

nataliaperina commented May 10, 2018

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.

@sede1971

This comment has been minimized.

sede1971 commented May 15, 2018

same problem :(

@evilebottnawi

This comment has been minimized.

Member

evilebottnawi commented May 15, 2018

Looks you have webpack installed globally

@sede1971

This comment has been minimized.

sede1971 commented May 15, 2018

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)

@ManuKle

This comment has been minimized.

ManuKle commented May 15, 2018

I have the same problem.
The thing is, it only happens on one machine (which is pretty much unusable because of that), but not on two others.
It doesn't matter whether webpack and webpack-cli are installed globally or not.
No matter what I do, it keeps asking me to install webpack-cli.

It has to be a configuration issue, but I don't have a clue what it might be...

@evilebottnawi

This comment has been minimized.

Member

evilebottnawi commented May 15, 2018

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

@ManuKle

This comment has been minimized.

ManuKle commented May 21, 2018

I got it working again.

I uninstalled npm and removed the cache (AppData\Roaming\npm and AppData\Roaming\npm-cache), reinstalled npm, cleaned the yarn cache (yarn cache clean) and finally, I removed my .yarnclean file because I noticed that some files were deleted which shouldn't have been.

Not sure which step it was in the end, but I'm happy that there's no errors anymore :)

@YOUNGmaxer

This comment has been minimized.

YOUNGmaxer commented May 24, 2018

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.

@deepakjha14

This comment has been minimized.

deepakjha14 commented May 26, 2018

try to install webpack-cli globally, after I installed this globally it got resolved as suggested by @YOUNGmaxer thanks !

@tsuf239

This comment has been minimized.

tsuf239 commented May 30, 2018

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

@taoeternal2018

This comment has been minimized.

taoeternal2018 commented Jun 14, 2018

problem solved with @YOUNGmaxer 's solution, thanks

@victufell

This comment has been minimized.

victufell commented Jul 1, 2018

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)

@ygnoh

This comment has been minimized.

ygnoh commented Jul 19, 2018

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 :)

@rakeshkumartiwari

This comment has been minimized.

rakeshkumartiwari commented Aug 14, 2018

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

@ashwani2797

This comment has been minimized.

ashwani2797 commented Aug 19, 2018

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)

@7043mcgeep

This comment has been minimized.

7043mcgeep commented Oct 12, 2018

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 :)

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)

I am getting the same pesky 'throw er' errors. I've tried uninstalling everything & reinstalling locally. Nothing helps. Has anyone found a fix?

@7043mcgeep

This comment has been minimized.

7043mcgeep commented Oct 12, 2018

The issue I was personally having (similar to above) was that the port I was trying to listen to was in use. So what fixed it for me was killing a background process of the server I was running, because I totally forgot it was running. See issue 1176: webpack/webpack-dev-server#1176

@seanlarge

This comment has been minimized.

seanlarge commented Oct 17, 2018

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): 
@davesnx

This comment has been minimized.

davesnx commented Nov 26, 2018

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.

@Q10Viking

This comment has been minimized.

Q10Viking commented Nov 28, 2018

npm install webpack-cli -g

Using the above command solved your problem

@MilanRaval

This comment has been minimized.

MilanRaval commented Dec 4, 2018

Global cli install fixed issue for me: npm install --global webpack-cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment