docker throwing error due to missing webpack configuration file

I've encountered an issue while trying to run my web app using webpack and docker. It works fine when I run "npm start" but not when I run it with docker.

Below are the errors that I am facing:

> webpack-dev-server --open --progress --config webpack.dev.js && npm run build:css -- -w

[webpack-cli] Failed to load '/usr/src/webpack.dev.js' config
[webpack-cli] Error: Cannot find module '/usr/src/webpack.dev.js'
Require stack:
- /usr/src/node_modules/webpack-cli/lib/webpack-cli.js
- /usr/src/node_modules/webpack-cli/lib/bootstrap.js
- /usr/src/node_modules/webpack-cli/bin/cli.js
- /usr/src/node_modules/webpack-dev-server/bin/webpack-dev-server.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:955:15)
    at Module._load (node:internal/modules/cjs/loader:803:27)
    at Module.require (node:internal/modules/cjs/loader:1021:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at WebpackCLI.tryRequireThenImport (/usr/src/node_modules/webpack-cli/lib/webpack-cli.js:204:22)
    at loadConfigByPath (/usr/src/node_modules/webpack-cli/lib/webpack-cli.js:1404:38)
    at /usr/src/node_modules/webpack-cli/lib/webpack-cli.js:1454:88
    at Array.map (<anonymous>)
    at WebpackCLI.loadConfig (/usr/src/node_modules/webpack-cli/lib/webpack-cli.js:1454:68)
    at WebpackCLI.createCompiler (/usr/src/node_modules/webpack-cli/lib/webpack-cli.js:1785:33) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/src/node_modules/webpack-cli/lib/webpack-cli.js',
    '/usr/src/node_modules/webpack-cli/lib/bootstrap.js',
    '/usr/src/node_modules/webpack-cli/bin/cli.js',
    '/usr/src/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
  ]
}

In my webpack setup, I have split the webpack config into 3 separate files as shown below:

1. webpack.common.js

const path = require('path');
const webpack = require('webpack');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const pkg = require('./package.json');
const name = pkg.name;
module.exports = {
    // webpack configuration details...
};

2. webpack.dev.js

const path = require("path");
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
module.exports = merge(common, {
    // webpack development configuration details...
});

3. webpack.prod.js

const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
module.exports = merge(common, {
    // webpack production configuration details...
});

In my package.json and Dockerfile, the configurations are as follows:

package.json

{
  // package.json details...
}

Dockerfile

FROM node:latest

# Dockerfile setup details...

I have tried various solutions including adding COPY . . in Dockerfile, but the issue persists. Any help or guidance in resolving this would be greatly appreciated.

Answer №1

Oops, my bad. I realized I should have used COPY . . instead of COPY ..

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

Issue encountered when attempting to use array.sort on values exceeding 1000

When I use the .sort() method on my firstArr example, it functions correctly. However, when I apply the .sort() method to secondArr, which contains values exceeding 1000, it malfunctions. I have attempted to locate information on any limitations of the . ...

How to define a different initial route using ui-router in AngularJS?

Is there a way to set a startup route for ui-router that differs from using $urlRouterProvider.otherwise()? Or is it possible to cleverly guide ui-router towards navigating to a different path upon initialization? ...

The playwright brings the curtain down on a blank page without a single word

I am working with code snippets const {chromium} = require('playwright'); (async () => { const userDataDir = '\NewData'; const browser = await chromium.launchPersistentContext(userDataDir,{headless:false}); const pag ...

implement a custom web server with a predefined root directory using a gulp task

After reviewing several gulp server instances (specifically using gulp-webserver), I'm having trouble locating where to specify the root folder for the server based on the parameters listed in the documentation here. Below is the code snippet in quest ...

Encountering errors while attempting to install TypeScript through NPM

I am encountering an issue while trying to install Typescript using npm. Following the documentation, I executed the command: npm install -g typescript or sudo npm install -g typescript - Everything seems to be going smoothly until it reaches about 2 ...

What is Angular's approach to handling a dynamic and unprocessed JSON object?

When a JSON file is placed under assets, accessing it using something like http://localhost:4200/myapp.com/assets/hello.json will fetch the JSON file directly without any graphical user interface. This indicates that Angular must be able to return a raw JS ...

How to showcase images and text from an array of objects using React

I'm currently working on a React lightbox that is supposed to display a loop of objects containing images and text. However, I'm facing an issue where the images are not showing up with the corresponding text label as intended. It seems like I a ...

The data remains stagnant even after employing the onDataChange function in react native following the integration of a reusable component

My reusable Text input component is not working properly for validation. I am unable to retrieve the input value as it always shows null. This is how I am retrieving the username and password: <LoginTextBox placeholderName='Email& ...

Submitting POST data to PHP using AJAX

Having always sent AJAX requests with jQuery, I am now faced with the challenge of sending them using 'vanilla' JS. Despite my best efforts, I have managed to get everything working except for passing the data along with the request. The two vari ...

JavaScript and HTTP Post parameters: Consider using optional additional parameters

Managing a filtration function, I have an array of checkboxes and dropdowns. Users can select multiple checkboxes and dropdown values before clicking on the "Filter Now" button. Upon clicking the button, a POST request is triggered to my API, passing alon ...

How can one access a specific element by its id that is located within an ng-template in Angular 6?

I have a question regarding accessing a button element inside an ng-template tag using its id in the TypeScript file. How can I accomplish that without encountering undefined errors? This is what I have tried so far: HTML <ng-template #popup > ...

I am looking to incorporate automatic scrolling functionality into my RSS Feed

I'm in the process of developing an RSS feed for my website. My expertise in JS/jQuery is limited, so any assistance would be greatly appreciated. After utilizing Google's Feed API and creating my own RSS Reader Widget, I realized that it lacked ...

Adding a picture to the webpage and saving it temporarily on the site

After exploring all options on the site, testing it rigorously and closely following the instructions provided, I am still unable to determine where exactly I went wrong. Website Link: The main goal is to upload an image and temporarily store it within t ...

Dealing with errors in Node.js using the Express framework and the

The code I'm having trouble with is shown below app.get('/', function(req, res, next) { if (id==8) { res.send('0e'); } else { next(); } }); app.use(function(err, req, res, next){ res.send(500, ' ...

A step-by-step guide on how to implement a window scroll-controlled color transition

I've implemented jQuery code to change the opacity of my navbar's background as the user scrolls, transitioning from transparent to blue. Here's the snippet: $(window).scroll(function(){ var range = $(this).scrollTop(); var limit = 45 ...

Functionality of jQuery Mobile Page

$(document).on("pageshow", "#mappage", function (event) { $("#doldur").append("<li> <label onclick='getBina(" + featuressokak[f].attributes.SOKAKID + ");'>" ...

Design a background image that is optimized for both high-resolution retina displays and standard non-ret

Scenario I am working on a web page where I want the background image to be fixed, covering the entire screen or window (excluding tablets and smartphones). The background image has been created using ImageShack. Everything is running smoothly so far. T ...

Breaking down and analyzing XML information

I have data that I need to retrieve from an XML file, split the result, parse it, and display it in an HTML element. Here is a snippet of the XML file: <Root> <Foo> <Bar> <BarType>Green</BarType> &l ...

Integrate Vue Login Functionality using Axios HTTP Requests

Hello everyone! I am new to Vue and currently struggling with making an HTTP Request to my backend. When I check the browser console, I can see the access token retrieved from /login endpoint but when I try to fetch data from api/users, it returns "Token ...

Having trouble with the toggle button on the Bootstrap 5 navbar?

I am facing an issue with my HTML code where the toggle button does not display properly when I resize the browser screen. Upon clicking on it, the navigation bar items do not show at all. Here is a screenshot of my website <html> <head> ...