Issues with npm and webpack-cli

Trying to run webpack as part of my build step fails, gives an error that the cli isn’t installed. Using the shell and trying to install the webpack-cli manually results in:

CLI for webpack must be installed.
webpack-cli (https://github.com/webpack/webpack-cli)

We will use "npm" to install the CLI via "npm install -D webpack-cli".
Do you want to install 'webpack-cli' (yes/no): yes

Installing 'webpack-cli' (running 'npm install -D webpack-cli')...
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules/webpack-cli" as it does not contain a package.json file.

webpack-cli is part of my package.json file but isn’t being installed automatically.

Hey there- could you share with me what your build command looks like, and where your service is calling webpack initially? Please feel free to DM me if you’d prefer to not publicly post that on a forum.

My initial thought here is that it should use webpack rather than webpack-cli if it’s being called from something like a package.json build script, which should avoid the problem.

1 Like

Thank you! I was calling webpack from my build shell script instead of calling it from npm run build. Oops! :man_facepalming:t2:

1 Like