Reputation: 131
I try to Dockerize a React app that uses webpack. Everything is working properly when I run my app locally (on MacOS).
But when I use docker I get a the following error:
ERROR in ./src/containers/fenetre_log.jsx
Module not found: Error: Can't resolve 'ROSLIB' in '/usr/src/app/src/containers'
The strange thing is that roslib is well declared as a dependency in my package.json...
Here is my package.json:
{
"license": "UNLICENSED",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"eslint": "^4.6.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.3.0",
"gh-pages": "^1.1.0",
"html-loader": "^0.5.1",
"html-webpack-plugin": "^3.2.0",
"node-sass": "^4.12.0",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"webpack": "^4.26.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
},
"dependencies": {
"net": "^1.0.2",
"react": "16.2",
"react-dom": "16.2",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-promise": "^0.6.0",
"roslib": "^1.1.0"
},
"scripts": {
"start": "webpack-dev-server --mode development --host 0.0.0.0",
"lint": "eslint './src/**/*.js' './src/**/*.jsx'",
"deploy": "webpack -p && gh-pages -d dist"
}
}
Here is my Dockerfile:
# Docker Image which is used as foundation to create
# a custom Docker Image with this Dockerfile
FROM node:10
# A directory within the virtualized Docker environment
# Becomes more relevant when using Docker Compose later
WORKDIR /usr/src/app
# Copies package.json and package-lock.json to Docker environment
COPY package*.json ./
# Installs all node packages
RUN npm install
# Copies everything over to Docker environment (except the .dockerignore files {cf bellow})
COPY . .
# Uses port which is used by the actual application
EXPOSE 8080
# Finally runs the application
CMD [ "npm", "start" ]
From where do you think the error message can come from ?
Here are the command I used to build and run the container:
docker build -t front-end .
docker run -tid --name front-end front-end
Then I checked the logs with :
docker logs front-end
Here is the .dockerignore :
/node_modules
Upvotes: 1
Views: 926
Reputation: 94
Without the actual code where the error originates, it's difficult to pinpoint the problem. If for some reason you cannot share your code publicly you can try below:
docker run -it [IMAGE_ID] sh
https://github.com/JeffreyWay/laravel-mix/issues/1741
Hope this helps.
Upvotes: 1