Error: The module was not found. Unable to locate 'bundle.js' within the directory path '/Users/jonathankuhl/Documents/Programming/node js/sandbox/webpack-app'

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?

Answer №1

To generate the bundle.js output file, consider using the following command:

webpack app.js -o bundle.js

Answer №2

Setting the mode explicitly was an essential step I couldn't overlook.

In order to follow along with the tutorial, I had to use this command: webpack --mode=development app.js -o bundle.js

It helped me progress in understanding the concepts being taught.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

the object '[object Object]' of a distinct supporting nature

I encountered an error stating "ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays." This is my TypeScript file: this.list = data.json(); ...

A step-by-step guide on utilizing links for downloading PDF files in Vue/Nuxt

Having some trouble opening a PDF tab in my Vue application with NUXT and Vuetify... any suggestions? I attempted to use: <a href="../static/docs/filename.pdf" target="_blank">Download PDF</a> I also tried using <nuxt-link> but it didn ...

Tips for determining whether a value is present in an array or not

I'm trying to prevent duplicate values from being pushed into the selectedOwners array. In the code snippet below, the user selects an owner, and if that owner already exists in the selectedOwners array, I do not want to push it again. How can I imple ...

Enable/disable specific dates in datepicker depending on dropdown selection

Struggling with disabling specific days of the week in the jQuery datepicker based on a selected dropdown option. Provided below is the snippet of my HTML and JavaScript code: <script> $("#dates").datepicker({ minDate: 0 }); </sc ...

What is the best way to incorporate an immediately invoked function expression (IIFE) within the return statement of a React

I currently have a modal that pops up when the user clicks a button on my page and it's functioning perfectly: render() { return ( <div> <section> <button onClick={() => this.refs.simpleDialog.show()}> ...

How to make Firefox display a user-friendly date value in a date input field when using Angular.js and HTML5?

I am working with an HTML5 date input and I want it to default to the value of the date property in my model. Formatting is not a big concern, as Chrome seems to handle that based on my locale, but ideally, I would like the format to be dd/MM/yyyy. Check ...

Leveraging ng-transclude and the require attribute for effective communication between directives

I'm working with two directives, let's call them: angular.module('app').directive('directiveX', directiveX); function directiveX(){ return { restrict: 'E', transclude: true, ...

Utilize jQuery to retrieve values from a Dropbox and Textbox and populate them inside a table

I'm attempting to retrieve values from a table row using the onfocus event. I have been assigned the task of inserting data into a database without clicking a button, so I decided to utilize the onfocus event for the last cell in the row. The challen ...

Use promises instead of directly calling res.json(data) when working with Node.js

When I make a post request to the payment_url, it triggers the second block of my function. Unfortunately, I am unable to retrieve any data in the then method because I am unsure how to pass the data back to the resolve function. Client-side call paypal. ...

What could be the reason for the absence of the loading sign in Chrome, even though it appears when the code is run on Firefox?

I implemented a function to display a loading screen on my HTML page with Google Maps integration. However, when I called the function popUpLoadingScreen() and dismissLoadingScreen() to show and hide the loading message while rendering map markers, the loa ...

Transferring information from a modal popup to a controller

I am attempting to pass parameters from a Bootstrap modal popup to my controller using Javascript and Ajax. However, when I click the button, it does not seem to work on the controller. How can I successfully send these parameters? Below is the HTML code ...

"An error has occurred: The file already exists" message is displayed while attempting to execute the initial command for Remix.run

I am not very familiar with the npx command, but as far as I understand, it is a way to execute NPM packages, a step required in the Getting started guide from the Remix.run web framework. It's quite frustrating to be stuck on the first step where I ...

Personalized style for text overflow property

The application is created using Angular. Within a component, we have a div containing some text: <div>abcdefghijklmnop<div> Depending on the screen size, the text should either be fully displayed or clipped. I discovered the property 'te ...

What is the procedure for obtaining the inverse of a Matrix3 within the context of three.js?

The documentation for three.js mentions that there is a function called Matrix3 which has a method called .getInverse. However, it requires a Matrix4 as the first parameter. I attempted to use this function in a simple way in version r71: var m = new TH ...

The concept of asynchronicity and callbacks in JavaScript

As a newcomer to the world of JavaScript and Stack Overflow, I have been learning about synchronous, asynchronous, and callbacks through various videos and blogs. However, I still have a lingering doubt. If synchronous code means following a sequential ord ...

Unable to install express due to error encountered during npm installation of express

During my attempt to install express, I encountered the following error messages: npm ERR! code ERR_OSSL_PEM_NO_START_LINE npm ERR! errno ERR_OSSL_PEM_NO_START_LINE npm ERR! request to https://registry.npmjs.org/express failed, reason: error:0909006C:P ...

Tips for choosing a class with a leading space in the name

Struggling with an issue here. I'm attempting to adjust the CSS of a specific div element that is being created dynamically. The current output looks something like this: <div class=" class-name"></div> It seems there is an extra space b ...

By default, the function is triggered automatically upon clicking the button

I am encountering an issue with the code provided below. The testFunction is being executed automatically when the button click event occurs (default behavior of the CMS I'm using). However, I would like to override this behavior and prevent the testF ...

Tips on retrieving a result from mongoose's findOne() function

I created a custom function using the findOne() method in Mongoose and now I need to use the result for another function. How can this be achieved? Thank you! module.exports.retrieveDeal = function(dealRequest){ Deal.findOne({name:dealRequest},functi ...

What are the steps to customize the index.html file within the build directory prior to serving it for each request using an Nginx server?

I need to make changes to the React index.html file on the server prior to delivering it to the browser upon request. My goal is to dynamically include open graph meta tags in the head based on the requested URL. Is there a way to accomplish this using N ...