I have been working on a project in Nuxt.js that was running smoothly on my Windows OS without Docker. However, when I tried to set it up inside Docker and run it, I encountered the following errors:
#9 126.5 ERROR in ./pages/index.vue
#9 126.5 Module not found: Error: Can't resolve './main/index.js?vue&type=script&lang=js&' in '/web/pages'
#9 126.5 @ ./pages/index.vue 2:0-61 3:0-56 3:0-56 10:2-8
...
executor failed running [/bin/sh -c apk update && apk upgrade && apk add git python3 && rm -rf node_modules && rm -rf .nuxt && node -v && npm install && npm audit fix && npm run build]: exit code: 1
For reference, here is the tree view of the pages
folder in my project:
https://i.sstatic.net/vPaZp.png
The configuration file for Nuxt looks like this:
const isDev = process.env.NODE_ENV !== 'production'
export default {
ssr: true,
...
}
My package.json
file contains the necessary dependencies and scripts for the project.
{
"name": "we",
"version": "1.0.0",
"private": true,
...
}
The main source of the errors seems to be within the index.vue
file:
<template>
<div>
<h2>Hello World></h2>
</div>
</template>
... // Other code here
Here is how the Dockerfile is set up:
FROM node:12.19.0-alpine3.12
ENV APP_ROOT /web
WORKDIR ${APP_ROOT}
ADD . ${APP_ROOT}
RUN rm -rf node_modules && \
...
npm run build
CMD ["npm", "run", "start"]
Why am I encountering these errors when running the project inside Docker?