Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
I get this error when running "webpack" from an npm script:
webpack not installed, consider installing it using
npm install --save-dev webpack
This only happens when I'm using require to a nonexisting module in the webpack.config.js.
If the current behavior is a bug, please provide the steps to reproduce.
This happens using a webpack.config.js file with just this line:
const a = require('a')
What is the expected behavior?
Not getting that error.
Please paste the results of webpack-cli info here, and mention other relevant information such as programming language.
System:
OS: Linux 4.4 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
Binaries:
Node: 10.15.3 - /usr/bin/node
Yarn: 1.16.0 - /usr/bin/yarn
npm: 6.4.1 - /usr/bin/npm
npmPackages:
webpack: ^4.33.0 => 4.33.0
webpack-cli: ^3.3.3 => 3.3.3
Okay this needs some fine tweaking. It's bc we assume webpack is throwing because you've not installed webpack compared to another module.
I see the same error in my project after I upgrade to the latest version 3.3.3, before, the error printed an exception with lots of code file information, and I can see the actual error "Cannot find module 'vue-loader/lib/plugin'", so I can check the missing plugin and install it to fix the issue, now it only show 'webpack not installed', I don't know what I can do to fix the issue, I have already installed webpack.
I saw the same error in my project, but actually it was hidding another error. After I changed the folder of my configuration file webpack.prod.js, I configured the path of it incorrectly. The error stoped after I fixed it.
Fixing now
I run into same issue - after some digging it appeared that my config file name had typo and webpack was not unable to find it... so error is missleading. No error is better than missleading one.
Pushing out a patch in a minute
3.3.5
I'm getting the same issue.. I ran webpack-cli and it tells me that webpack is in npmGlobalPackages.
If i run webpack i get 'webpack is not installed'.
My simple webpack.config.js looks like this.
`const path = require('path');
module.exports = {
mode: 'development',
entry: {
myapp: './src/index.js',
},
output: {
path: path.resolve(__dirname, 'www/js'),
filename: '[name]_bundle.js',
},
devtool: 'inline-source-map',
};`
path - is installed.
I even did . sudo npm install -g webpack.
Even sudo webpack. It's not found. Could it possibly be more broken?
To make this even more messed up, I have another project, in a nearby folder. it has webpack working.
Could you make a repository with reproduction of the issue? @BradWebflex
Execute: " npm install --save-dev webpack-cli " in your project.
It worked for me
Most helpful comment
Execute: " npm install --save-dev webpack-cli " in your project.
It worked for me