Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

docker-compose image does not install graphql #154

Open
Joshfindit opened this issue Aug 28, 2021 · 2 comments
Open

docker-compose image does not install graphql #154

Joshfindit opened this issue Aug 28, 2021 · 2 comments

Comments

@Joshfindit
Copy link

  1. Cloned the repo
  2. docker-compose up
  3. It failed because the api container did not start
  4. Did docker-compose run api bash, then npm install graphql
  5. api container now starts
...
added 230 packages from 189 contributors, removed 21 packages, updated 195 packages and audited 928 packages in 29.399s

67 packages are looking for funding
  run `npm fund` for details

found 23 vulnerabilities (21 moderate, 2 high)
  run `npm audit fix` to fix them, or `npm audit` for details
root@0ef28cc3b210:/app# npm start

> grand-stack-starter-api@0.0.1 start /app
> npm run build && node build/index.js


> grand-stack-starter-api@0.0.1 build /app
> babel src --out-dir build && shx cp .env build 2>/dev/null || : && shx cp src/schema.graphql build

Successfully compiled 5 files with Babel (1136ms).
internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'graphql'
Require stack:
- /app/node_modules/apollo-server-errors/dist/index.js
- /app/node_modules/apollo-server-core/dist/runHttpQuery.js
- /app/node_modules/apollo-server-core/dist/index.js
- /app/node_modules/apollo-server-express/dist/index.js
- /app/build/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/app/node_modules/apollo-server-errors/dist/index.js:4:19)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/app/node_modules/apollo-server-errors/dist/index.js',
    '/app/node_modules/apollo-server-core/dist/runHttpQuery.js',
    '/app/node_modules/apollo-server-core/dist/index.js',
    '/app/node_modules/apollo-server-express/dist/index.js',
    '/app/build/index.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grand-stack-starter-api@0.0.1 start: `npm run build && node build/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grand-stack-starter-api@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-08-28T11_48_13_418Z-debug.log



root@0ef28cc3b210:/app# npm install graphql
npm WARN grand-stack-starter-api@0.0.1 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/nodemon/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ graphql@15.5.1
added 1 package and audited 929 packages in 10.719s

67 packages are looking for funding
  run `npm fund` for details

found 23 vulnerabilities (21 moderate, 2 high)
  run `npm audit fix` to fix them, or `npm audit` for details
root@0ef28cc3b210:/app# npm start

> grand-stack-starter-api@0.0.1 start /app
> npm run build && node build/index.js


> grand-stack-starter-api@0.0.1 build /app
> babel src --out-dir build && shx cp .env build 2>/dev/null || : && shx cp src/schema.graphql build

Successfully compiled 5 files with Babel (744ms).
GraphQL server ready at http://0.0.0.0:4001/graphql
@nola-it
Copy link

nola-it commented Sep 11, 2021

I have solved this by updating the Dockerfile for the api project adding the following:

RUN npm i graphql

So that my api Dockerfile looks like:

FROM node:12

RUN mkdir -p /app
WORKDIR /app

COPY package.json .
RUN npm install
RUN npm i graphql
COPY . .

EXPOSE 4001

CMD ["npm", "start"]

@guglielmo
Copy link

guglielmo commented Sep 12, 2021

Added "graphql": "^15.5.1" to dependencies in package.json and it seems to be working, too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants