0

I receive Cannot find module 'common-package' when trying to link to locally built package inside docker container. Package is built as part of the same Dockerfile, so I end up with following structure inside container.

home
  node
    common-package
    react-app

Package.json sits right inside react-app directory. In package.json I have the following dependency:

"common-package": "link:../common-package"

My Dockerfile:

FROM node:18.7.0-alpine

RUN apk update && apk add python3 make g++ yarn

RUN mkdir -p /home/node/react-app/node_modules && chown -R node:node /home/node/react-app

RUN mkdir -p /home/node/common-package/node_modules && chown -R node:node /home/node/common-package

WORKDIR /home/node/common-package

COPY ./ProjectA/Common/CommonPackage ./

USER root

RUN yarn

USER node

RUN yarn build

WORKDIR /home/node/react-app

COPY ./ProjectB/ReactApp/fe ./

USER root

RUN yarn

USER node

EXPOSE 3000

CMD [ "node", "./server/bootstrap.ts" ]

The error looks straight forward and surely is something obvious, but I ran out of ideas. Any help would be appreciated

  • Does this answer your question? [Cannot find module for a node js app running in a docker compose environment](https://stackoverflow.com/questions/42040317/cannot-find-module-for-a-node-js-app-running-in-a-docker-compose-environment) – Ahmed Sbai Jan 17 '23 at 16:38
  • Unfortunately it doesn't. I found this answer quite useful https://stackoverflow.com/questions/53379945/local-nodejs-module-not-being-found-by-docker – M.Pogorzelski Jan 18 '23 at 12:41

0 Answers0