Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

dockerised react.js app, module not found

I need to dockerize my react app, but incurring in some troubles:

Compiled with problems:

ERROR in ./node_modules/graphql-tag/lib/index.js 2:0-32

Module not found: Error: Can't resolve 'graphql' in '/app/node_modules/graphql-tag/lib'


ERROR in ./node_modules/@apollo/client/core/LocalState.js 3:0-39

Module not found: Error: Can't resolve 'graphql' in '/app/node_modules/@apollo/client/core'


ERROR in ./node_modules/@apollo/client/link/http/createHttpLink.js 3:0-32

Module not found: Error: Can't resolve 'graphql' in '/app/node_modules/@apollo/client/link/http'


ERROR in ./node_modules/@apollo/client/link/http/selectHttpOptionsAndBody.js 2:0-32

Module not found: Error: Can't resolve 'graphql' in '/app/node_modules/@apollo/client/link/http'


ERROR in ./node_modules/@apollo/client/utilities/globals/fix-graphql.js 2:0-33

Module not found: Error: Can't resolve 'graphql' in '/app/node_modules/@apollo/client/utilities/globals'


ERROR in ./node_modules/@apollo/client/utilities/graphql/directives.js 2:0-32

Module not found: Error: Can't resolve 'graphql' in '/app/node_modules/@apollo/client/utilities/graphql'


ERROR in ./node_modules/@apollo/client/utilities/graphql/transform.js 3:0-32

Module not found: Error: Can't resolve 'graphql' in '/app/node_modules/@apollo/client/utilities/graphql'

here’s my dockerfile:

FROM node:13.12.0-alpine

# set working directory
WORKDIR /app

# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install
RUN npm install react-scripts@latest -g
run npm build

# add app
COPY . ./

# start app
CMD ["npm", "start"]

here’s my docker-compose

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

version: '3.3'

services:
  propoly:
    build: .
    ports:
      - 3002:3002

here’s my package.json:

{
  "name": "insurance_microfrontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@apollo/client": "^3.5.6",
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.2"
  },
  "scripts": {
    "start": "PORT=3002 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

>Solution :

graphql is not listed in your package.json

Run npm i --save graphql, then rebuild your Docker container.

This should fix the error.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading