React.js Docker - Module not found
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Prerequisites
Linux 18.04
create-react-app 2.0
docker 19.09.0
Dockerfile
# base image
FROM node:9.6.1
# set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
ADD package.json /package.json
# install and cache app dependencies
COPY package.json /usr/src/app/package.json
RUN npm install --save --silent
RUN npm install react-scripts@latest -g --silent
# start app
CMD ["npm", "start"]
docker-compose.yml
version: '3.5'
services:
provisioning-app:
container_name: prv-app
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- '3000:3000'
environment:
- NODE_ENV=development
Problem
Everything has been working just fine, but after installing a new package docker stopped working as expected. Every time I run docker-compose up
it fails with 'Module not found' error.
While npm start
works perfectly fine.
I've tried quite a few workarounds found on the web:
- restart PC
- delete node_modules folder and run
npm i
again - different combinations of
npm install
/--save
/ including --save in Dockerfile
It just doesn't work and I can't handle it on my own. Any ideas why this might be happening?
Update
Weirdly, but this code works. I'm a rookie in Docker, so I have no clue what's the difference
docker run -it
-v $PWD:/usr/src/app
-v /usr/src/app/node_modules
-p 3000:3000
--rm
prov-app
reactjs docker docker-compose
add a comment |
Prerequisites
Linux 18.04
create-react-app 2.0
docker 19.09.0
Dockerfile
# base image
FROM node:9.6.1
# set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
ADD package.json /package.json
# install and cache app dependencies
COPY package.json /usr/src/app/package.json
RUN npm install --save --silent
RUN npm install react-scripts@latest -g --silent
# start app
CMD ["npm", "start"]
docker-compose.yml
version: '3.5'
services:
provisioning-app:
container_name: prv-app
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- '3000:3000'
environment:
- NODE_ENV=development
Problem
Everything has been working just fine, but after installing a new package docker stopped working as expected. Every time I run docker-compose up
it fails with 'Module not found' error.
While npm start
works perfectly fine.
I've tried quite a few workarounds found on the web:
- restart PC
- delete node_modules folder and run
npm i
again - different combinations of
npm install
/--save
/ including --save in Dockerfile
It just doesn't work and I can't handle it on my own. Any ideas why this might be happening?
Update
Weirdly, but this code works. I'm a rookie in Docker, so I have no clue what's the difference
docker run -it
-v $PWD:/usr/src/app
-v /usr/src/app/node_modules
-p 3000:3000
--rm
prov-app
reactjs docker docker-compose
add a comment |
Prerequisites
Linux 18.04
create-react-app 2.0
docker 19.09.0
Dockerfile
# base image
FROM node:9.6.1
# set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
ADD package.json /package.json
# install and cache app dependencies
COPY package.json /usr/src/app/package.json
RUN npm install --save --silent
RUN npm install react-scripts@latest -g --silent
# start app
CMD ["npm", "start"]
docker-compose.yml
version: '3.5'
services:
provisioning-app:
container_name: prv-app
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- '3000:3000'
environment:
- NODE_ENV=development
Problem
Everything has been working just fine, but after installing a new package docker stopped working as expected. Every time I run docker-compose up
it fails with 'Module not found' error.
While npm start
works perfectly fine.
I've tried quite a few workarounds found on the web:
- restart PC
- delete node_modules folder and run
npm i
again - different combinations of
npm install
/--save
/ including --save in Dockerfile
It just doesn't work and I can't handle it on my own. Any ideas why this might be happening?
Update
Weirdly, but this code works. I'm a rookie in Docker, so I have no clue what's the difference
docker run -it
-v $PWD:/usr/src/app
-v /usr/src/app/node_modules
-p 3000:3000
--rm
prov-app
reactjs docker docker-compose
Prerequisites
Linux 18.04
create-react-app 2.0
docker 19.09.0
Dockerfile
# base image
FROM node:9.6.1
# set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
ADD package.json /package.json
# install and cache app dependencies
COPY package.json /usr/src/app/package.json
RUN npm install --save --silent
RUN npm install react-scripts@latest -g --silent
# start app
CMD ["npm", "start"]
docker-compose.yml
version: '3.5'
services:
provisioning-app:
container_name: prv-app
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- '3000:3000'
environment:
- NODE_ENV=development
Problem
Everything has been working just fine, but after installing a new package docker stopped working as expected. Every time I run docker-compose up
it fails with 'Module not found' error.
While npm start
works perfectly fine.
I've tried quite a few workarounds found on the web:
- restart PC
- delete node_modules folder and run
npm i
again - different combinations of
npm install
/--save
/ including --save in Dockerfile
It just doesn't work and I can't handle it on my own. Any ideas why this might be happening?
Update
Weirdly, but this code works. I'm a rookie in Docker, so I have no clue what's the difference
docker run -it
-v $PWD:/usr/src/app
-v /usr/src/app/node_modules
-p 3000:3000
--rm
prov-app
reactjs docker docker-compose
reactjs docker docker-compose
edited Nov 16 '18 at 4:19
Nikita Neganov
asked Nov 15 '18 at 12:50
Nikita NeganovNikita Neganov
15711
15711
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Everything has been working just fine, but after installing a new
package docker stopped working as expected. Every time I run
docker-compose up it fails with 'Module not found' error.
You need to rebuild your image to have that package installed. docker-compose build
, and then docker-compose up
EDIT
Based on your update, I realize that the problem is your old node_module volume persisted between builds. Try docker-compose down -v
before up
.
It is not a good idea to build and up container on every new package wich installed after first build.
– Tazo leladze
Nov 15 '18 at 13:11
I don't understand what you are suggesting
– Siyu
Nov 15 '18 at 14:48
Neither did this one, doesn't woks as well
– Nikita Neganov
Nov 16 '18 at 3:55
try updated answer
– Siyu
Nov 17 '18 at 17:54
add a comment |
Instead of:
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
Try:
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
Nope, that made no difference
– Nikita Neganov
Nov 16 '18 at 3:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53319877%2freact-js-docker-module-not-found%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Everything has been working just fine, but after installing a new
package docker stopped working as expected. Every time I run
docker-compose up it fails with 'Module not found' error.
You need to rebuild your image to have that package installed. docker-compose build
, and then docker-compose up
EDIT
Based on your update, I realize that the problem is your old node_module volume persisted between builds. Try docker-compose down -v
before up
.
It is not a good idea to build and up container on every new package wich installed after first build.
– Tazo leladze
Nov 15 '18 at 13:11
I don't understand what you are suggesting
– Siyu
Nov 15 '18 at 14:48
Neither did this one, doesn't woks as well
– Nikita Neganov
Nov 16 '18 at 3:55
try updated answer
– Siyu
Nov 17 '18 at 17:54
add a comment |
Everything has been working just fine, but after installing a new
package docker stopped working as expected. Every time I run
docker-compose up it fails with 'Module not found' error.
You need to rebuild your image to have that package installed. docker-compose build
, and then docker-compose up
EDIT
Based on your update, I realize that the problem is your old node_module volume persisted between builds. Try docker-compose down -v
before up
.
It is not a good idea to build and up container on every new package wich installed after first build.
– Tazo leladze
Nov 15 '18 at 13:11
I don't understand what you are suggesting
– Siyu
Nov 15 '18 at 14:48
Neither did this one, doesn't woks as well
– Nikita Neganov
Nov 16 '18 at 3:55
try updated answer
– Siyu
Nov 17 '18 at 17:54
add a comment |
Everything has been working just fine, but after installing a new
package docker stopped working as expected. Every time I run
docker-compose up it fails with 'Module not found' error.
You need to rebuild your image to have that package installed. docker-compose build
, and then docker-compose up
EDIT
Based on your update, I realize that the problem is your old node_module volume persisted between builds. Try docker-compose down -v
before up
.
Everything has been working just fine, but after installing a new
package docker stopped working as expected. Every time I run
docker-compose up it fails with 'Module not found' error.
You need to rebuild your image to have that package installed. docker-compose build
, and then docker-compose up
EDIT
Based on your update, I realize that the problem is your old node_module volume persisted between builds. Try docker-compose down -v
before up
.
edited Nov 16 '18 at 9:44
answered Nov 15 '18 at 13:09
SiyuSiyu
3,30211231
3,30211231
It is not a good idea to build and up container on every new package wich installed after first build.
– Tazo leladze
Nov 15 '18 at 13:11
I don't understand what you are suggesting
– Siyu
Nov 15 '18 at 14:48
Neither did this one, doesn't woks as well
– Nikita Neganov
Nov 16 '18 at 3:55
try updated answer
– Siyu
Nov 17 '18 at 17:54
add a comment |
It is not a good idea to build and up container on every new package wich installed after first build.
– Tazo leladze
Nov 15 '18 at 13:11
I don't understand what you are suggesting
– Siyu
Nov 15 '18 at 14:48
Neither did this one, doesn't woks as well
– Nikita Neganov
Nov 16 '18 at 3:55
try updated answer
– Siyu
Nov 17 '18 at 17:54
It is not a good idea to build and up container on every new package wich installed after first build.
– Tazo leladze
Nov 15 '18 at 13:11
It is not a good idea to build and up container on every new package wich installed after first build.
– Tazo leladze
Nov 15 '18 at 13:11
I don't understand what you are suggesting
– Siyu
Nov 15 '18 at 14:48
I don't understand what you are suggesting
– Siyu
Nov 15 '18 at 14:48
Neither did this one, doesn't woks as well
– Nikita Neganov
Nov 16 '18 at 3:55
Neither did this one, doesn't woks as well
– Nikita Neganov
Nov 16 '18 at 3:55
try updated answer
– Siyu
Nov 17 '18 at 17:54
try updated answer
– Siyu
Nov 17 '18 at 17:54
add a comment |
Instead of:
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
Try:
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
Nope, that made no difference
– Nikita Neganov
Nov 16 '18 at 3:54
add a comment |
Instead of:
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
Try:
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
Nope, that made no difference
– Nikita Neganov
Nov 16 '18 at 3:54
add a comment |
Instead of:
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
Try:
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
Instead of:
volumes:
- '.:/usr/src/app'
- '/usr/src/app/node_modules'
Try:
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
edited Nov 15 '18 at 18:41
answered Nov 15 '18 at 13:05
Tazo leladzeTazo leladze
564619
564619
Nope, that made no difference
– Nikita Neganov
Nov 16 '18 at 3:54
add a comment |
Nope, that made no difference
– Nikita Neganov
Nov 16 '18 at 3:54
Nope, that made no difference
– Nikita Neganov
Nov 16 '18 at 3:54
Nope, that made no difference
– Nikita Neganov
Nov 16 '18 at 3:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53319877%2freact-js-docker-module-not-found%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown