Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AwilixResolutionError: Could not resolve 'authService'. #119

Closed
Wingrammer opened this issue Aug 17, 2022 · 6 comments
Closed

AwilixResolutionError: Could not resolve 'authService'. #119

Wingrammer opened this issue Aug 17, 2022 · 6 comments

Comments

@Wingrammer
Copy link

Wingrammer commented Aug 17, 2022

Describe the bug
When I try to run the docker image of my medusa app it is failing on AwilixResolutionError: Could not resolve 'authService'.

{"activity_id":"01GANBHPAKPBT7TR68TPPXW5VX","duration":1025,"level":"info","message":"Database initialized","timestamp":"2022-08-17 07:33:38"}
jungle-server-default | {"activity_id":"01GANBHQANZY3J22FP0K1XMBRX","config":{},"level":"info","message":"Initializing strategies","timestamp":"2022-08-17 07:33:38"}
jungle-server-default | {"activity_id":"01GANBHQANZY3J22FP0K1XMBRX","duration":1,"level":"info","message":"Strategies initialized","timestamp":"2022-08-17 07:33:38"}
jungle-server-default | {"activity_id":"01GANBHQAQYAW8PSPAJ6CJPFV3","config":{},"level":"info","message":"Initializing services","timestamp":"2022-08-17 07:33:38"}
jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - UserService
jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - ProductService
jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - OrderService
jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - StoreService
jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - InviteService
jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] 0 services registered
jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] 5 services overridden
jungle-server-default | {"activity_id":"01GANBHQAQYAW8PSPAJ6CJPFV3","duration":4,"level":"info","message":"Services initialized","timestamp":"2022-08-17 07:33:38"}
jungle-server-default | {"activity_id":"01GANBHQAWVZ6141F3XCPQ61HF","config":{},"level":"info","message":"Initializing express","timestamp":"2022-08-17 07:33:38"}
jungle-server-default | /app/jungle/node_modules/@medusajs/medusa/node_modules/awilix/lib/container.js:240
jungle-server-default | throw new errors_1.AwilixResolutionError(name, resolutionStack);
jungle-server-default | ^
jungle-server-default |
jungle-server-default | AwilixResolutionError: Could not resolve 'authService'.
jungle-server-default |
jungle-server-default | Resolution path: authService
jungle-server-default | at Object.resolve (/app/jungle/node_modules/@medusajs/medusa/node_modules/awilix/lib/container.js:240:23)
jungle-server-default | at /app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:51:37
jungle-server-default | at step (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:33:23)
jungle-server-default | at Object.next (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:14:53)
jungle-server-default | at /app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:8:71
jungle-server-default | at new Promise ()
jungle-server-default | at __awaiter (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:4:12)
jungle-server-default | at /app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:48:12
jungle-server-default | at /app/jungle/node_modules/@medusajs/medusa/dist/loaders/index.js:161:65
jungle-server-default | at step (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/index.js:52:23)
jungle-server-default | at Object.next (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/index.js:33:53)
jungle-server-default | at fulfilled (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/index.js:24:58)
jungle-server-default | at processTicksAndRejections (node:internal/process/task_queues:96:5)
jungle-server-default |
jungle-server-default | Node.js v17.1.0

To Reproduce
Steps to reproduce the behavior:

  1. Configure your dockerfile and docker-compose.yml
  2. Run docker compose -f docker-compose.yml up --build
  3. See error

Expected behavior
Server should successfully start

Screenshots

Package version:
Ubuntu 20.04
postgres: 14
node 17.1.0
npm@latest
"@medusajs/medusa": "^1.3.1",
"@medusajs/medusa-cli": "^1.3.0",
"@types/jsonwebtoken": "^8.5.8",
"awilix": "4.2.3",
"medusa-extender": "^1.7.2",
"medusa-file-minio": "^1.0.4",
"medusa-fulfillment-manual": "^1.1.26",
"medusa-interfaces": "^1.3.0",
"medusa-payment-manual": "^1.0.8",
"medusa-payment-stripe": "^1.1.30",
"mongoose": "^5.13.3",
"typeorm": "^0.2.45"
"@babel/cli": "^7.14.3",
"@babel/core": "^7.14.3",
"@babel/preset-typescript": "^7.14.5",
"babel-preset-medusa-package": "^1.1.13",
"nodemon": "^2.0.15",
"ts-node": "^10.7.0",
"typescript": "^4.5.5"

Additional context
The error is not occuring in development outside docker container
/app/jungle is my docker workdir

@adrien2p
Copy link
Owner

Can i get you to rename the issue please 😊

Also, can you share you docker files please. Because it is probably not link to the extender but might be a config issue

@Wingrammer Wingrammer changed the title [BUG] [BUG] AwilixResolutionError: Could not resolve 'authService'. Aug 17, 2022
@Wingrammer
Copy link
Author

Wingrammer commented Aug 17, 2022

Sorry for the untitled issue. Here are the docker files
Dockerfile.txt

FROM node:17.1.0 WORKDIR /app/jungle COPY package*.json ./ COPY . . RUN apt-get update RUN apt-get install -y python RUN npm install -g npm@latest RUN npm install -g @medusajs/medusa-cli@latest RUN npm install RUN npm run build ENTRYPOINT ["./develop.sh"]
docker-compose.txt

`
version: "3.8"
services:
backend:
build:
context: .
dockerfile: Dockerfile
image: backend:starter
container_name: jungle-server-default
depends_on:
- postgres
- redis
environment:
PORT: 9000
DB_HOST: postgres
DB_PORT: 5432
DB_USERNAME: docker
DB_PASSWORD: docker
DB_SCHEME: docker-db
JWT_SECRET: startwiththis
JWT_EXPIRESIN: 15
COOKIE_SECRET: secret
REDIS_URL: redis://redis
ADMIN_CORS: http://localhost:7000,http://localhost:7001
STORE_CORS: http://localhost:8000
ports:
- "9000:9000"
volumes:
- .:/app/jungle
- node_modules:/app/jungle/node_modules

postgres:
image: postgres:14
ports:
- "6432:5432"
environment:
POSTGRES_USER: docker
POSTGRES_PASSWORD: docker
POSTGRES_DB: docker-db
POSTGRES_PORT: 6432
POSTGRES_HOST: postgres

redis:
image: redis
expose:
- 6379

volumes:
node_modules:
`

@adrien2p
Copy link
Owner

The develop.sh file, what does it contains?

@Wingrammer
Copy link
Author

#!/bin/bash
                # I tried with and without seeding
                npm run seed

		#Run migrations to ensure the database is updated
		medusa migrations run
		
		#Start development environment
		npm run start:test

The package.json scripts:

"scripts": {


        "seed": "medusa seed -f ./data/seed.json",
        "build": "rm -rf dist && ./node_modules/.bin/tsc -p tsconfig.json",
        "start": "npm run build && NODE_ENV=development node ./dist/main.js",
        "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
        "start:watch": "nodemon --watch './src/**/*.ts' --exec 'ts-node' ./src/main.ts",
        "start:prod": "npm run build && NODE_ENV=production node dist/main",
        "start:test": "npm run build && NODE_ENV=test node dist/main",
        "serve": "medusa start",
        "heroku-postbuild": "medusa migrations run",
        "prepare": "npm run build"


    }

@adrien2p
Copy link
Owner

adrien2p commented Aug 17, 2022

It seam that you are missing the medex migration as well as the .js at the end of the start:test command.

Also, the test command set the env to test which tells to medusa to load the test deps which are just the mocks. You should run npm start instead

@adrien2p adrien2p changed the title [BUG] AwilixResolutionError: Could not resolve 'authService'. AwilixResolutionError: Could not resolve 'authService'. Aug 17, 2022
@Wingrammer
Copy link
Author

It seam that you are missing the medex migration as well as the .js at the end of the start:test command.

Also, the test command set the env to test which tells to medusa to load the test deps which are just the mocks. You should run npm start instead

Alright thank you. After following those steps it was fixed

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

No branches or pull requests

2 participants