3

I'm preparing a Dockerfile that will be used in production. But for some reason, the last command is returning an error.

react_1  | [WEBPACK] Building 1 target
react_1  | [WEBPACK] Started building bundle.[chunkhash].js
react_1  | [WEBPACK] Build failed after 33.631 seconds
react_1  | [WEBPACK] Errors building bundle.[chunkhash].js
react_1  | Module not found: Error: Can't resolve './App' in '/home/app/react/src'

Here is the copy of the docker file

Dockerfile.prod

FROM node:7.10.1-alpine

RUN apk update
ENV HOME=/home/app
COPY . $HOME/react/
RUN npm install yarn -g

WORKDIR $HOME/react
RUN mkdir build && mkdir dlls && yarn

CMD ["yarn", "start:prod"]

Here's the copy of the docker-compose file

docker-compose.prod.yml

version: '3.1'
services:
  react:
    build:
      context: .
      dockerfile: Dockerfile.prod
    ports:
      - 3100:3100
    volumes:
      - /home/app/react

When I docker-compose -f docker-compose.prod.yml up --build -d it works as expected until when it builds the webpack file. But fails as you can see in the error above.

But when I do this docker-compose run react yarn start:prod the webpack builds just fine.

Here's the repo in question.

2
  • I am getting same error for start:dev and start:prod Module not found: Error: Can't resolve './App' in '/home/app/react/src' Commented Aug 30, 2017 at 16:34
  • 1
    try import { App } from './App'; - instead of import App from './App'... expecially where export default class App Commented Aug 30, 2017 at 17:20

1 Answer 1

4

My bad. It was case sensitive errors. Since I was on windows it just went through without problems.

So the error happened because the import statement was finding App folder, but the actual folder was app.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.