Basically I'm setting up webpack and when I tried getting dev-server in development mode in webpack, I ran into this Error.
I tried following some instructions in other things, tried from beginning twice, but still getting the same error. I can't figure out what I am doing wrong here. If anyone has solution onto this issue, I'd very much appreciate that. Thanks.
Error I'm getting:
bundle.js:20 Uncaught TypeError: Cannot read property 'call' of undefined
at __webpack_require__ (bundle.js:20)
at eval (index.js:2)
at Object../src/js/index.js (bundle.js:357)
at __webpack_require__ (bundle.js:20)
at eval (webpack:///multi_(:8080/webpack)-dev-server/client?:2:18)
at Object.0 (bundle.js:368)
at __webpack_require__ (bundle.js:20)
at bundle.js:69
at bundle.js:72
Specifics of error:
// Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
webpack.config.js:
const path = require('path');
module.exports = {
entry: './src/js/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/bundle.js'
},
devServer: {
contentBase: './dist'
}
};
package.json:
{
"name": "forkify",
"version": "1.0.0",
"description": "forkify project",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
},
"author": "Jonas Schmedtmann",
"license": "ISC",
"devDependencies": {
"webpack": "^4.2.0"
},
"dependencies": {
"webpack-cli": "^2.1.5",
"webpack-dev-server": "^3.4.1"
}
}
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="js/bundle.js"></script>
</body>
</html>
I expect any solutions to this.
I encountered the same issue yesterday and went through a lot of discussions online. Few suggested that it is due to a bug in webpack-dev-server and few suggested it is due to improper imports of the chunks. But none of it was the case with me as I was generating a single chunk file. What worked for me is to remove the node_modules folder completely and do a fresh npm install. Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With