I wrote a DockerFile for a node application. This is the docker file:
FROM node:10.15.0
COPY frontend/ frontend/
WORKDIR frontend/
RUN npm install
RUN npm start
When I try to build this Dockerfile, I get this error: ERROR in ./app/main.js Module not found: Error: Can't resolve './ResetPwd' in '/frontend/app'
So I added RUN ls
& RUN ls /app
in Dockerfile. Both of the files are there! I'm not familiar with NodeJS and it's build process at all. Can anybody help me with this?
Point: I'm not sure if it helps or not, but I'm using Webpack too.
If you are trying to run your Node.js application and you get something like this: Error: Cannot find module 'C:UsersMemy_app.js'. then you are most likely trying to run the wrong file.
The common way is to create a Dockerfile that is already aware of your application, and make it copy your package.json file and perform an npm install.
As far as I can see you're not doing any installation when starting the container, so the contents of the mount are empty. If you remove that mount, the node_modules path will be populated with what was installed during the docker build (as defined by the Dockerfile) phase.
If you are trying to run your Node.js application and you get something like this: then you are most likely trying to run the wrong file. It is possible you are missing a dependency that is needed from npm install , but if it says it cannot find the main file you are trying to run, then you are trying to run a file that does not exist.
The problem was that our front-end developer considered that node imports are case insensitive and he was using windows. I tried to run Dockerfile on mac and that's why it couldn't find the modules. Module name was resetPass!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With