I am in the process of working through a tutorial on Webpack, but after adding in HtmlWebpackPlugin and trying to run Webpack again, I get the following error:
Error: Cannot find module 'html-webpack-plugin'
at Function.Module._resolveFilename (module.js:489:15)
...
I have tried installing the plugin both locally and globally and I get the error both times.
//webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: "./app.js", // bundle entry point
output: {
path: path.resolve(__dirname, 'dist'), // output directory
filename: "[name].js" // name of generated bundle
},
plugins : [
new HtmlWebpackPlugin({
template: "index.html",
inject: "body"
})
]
};
//package.json
{
"name": "hyperlocalnola",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"html-webpack-plugin": "^2.30.1"
}
}
//app.js
var msg = require("./contents.js");
document.write(msg);
//contents.js
module.exports = "hello friend!";
Sorry about the wall of text for what is probably something very simple, but I cannot find what is causing this anywhere. Thanks in advance.