I am currently following a basic tutorial on Webpack, but I am facing difficulties in compiling a simple one-line JavaScript application. Despite installing and uninstalling it multiple times, the compilation process seems to be unsuccessful.
This tutorial aims to help me understand how to use Webpack. I used npm init
to set up my package.json
file without making any other alterations to it. I have an index.html file and an app.js file that are supposed to bundle into a file named bundle.js.
When I enter the command webpack app.js bundle.js
into the terminal, I consistently receive the following error:
ERROR in multi ./app.js bundle.js
Module not found: Error: Can't resolve 'bundle.js' in '/Users/jonathankuhl/Documents/Programming/node js/sandbox/webpack-app'
@ multi ./app.js bundle.js
Additionally, here is the content of my package.json file, which only includes information generated through npm init
:
{
"name": "webpack-app",
"version": "1.0.0",
"description": "testing",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"webpack": "^4.1.1"
}
}
I've attempted various alternatives such as using npm run build
after adding "build":"webpack"
to the scripts section of my package.json file, with no success. This was done before deleting the entire directory and starting anew. Additionally, I have reinstalled webpack and webpack-cli multiple times.
I am unsure of what I am doing incorrectly. I am following the tutorial step by step, and while I am not very familiar with webpack, I decided to explore it since I aspire to work in web development. The error message stating "can't resolve 'bundle.js'" confuses me, as bundle.js should be created by webpack itself.
If it helps, the tutorial I am following can be found here: https://www.youtube.com/watch?v=lziuNMk_8eQ. It was published less than a year ago, so there could be some slight differences due to updates?