medusa icon indicating copy to clipboard operation
medusa copied to clipboard

When I try starting the server using the medusa-file-s3 plugin it crushes with this TypeError

Open Wingrammer opened this issue 3 years ago • 4 comments

Bug report

Describe the bug

When I run the server I get this error:

/home/backend/node_modules/medusa-file-s3/services/s3.js:32 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } ^

TypeError: Super expression must either be null or a function at _inherits (/home/backend/node_modules/medusa-file-s3/services/s3.js:32:113) at /home/backend/node_modules/medusa-file-s3/services/s3.js:47:3 at Object. (/home/backend/node_modules/medusa-file-s3/services/s3.js:203:2) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at /home/backend/node_modules/@medusajs/medusa/dist/loaders/plugins.js:302:50 at step (/home/backend/node_modules/@medusajs/medusa/dist/loaders/plugins.js:33:23) at Object.next (/home/backend/node_modules/@medusajs/medusa/dist/loaders/plugins.js:14:53) at /home/backend/node_modules/@medusajs/medusa/dist/loaders/plugins.js:8:71 at new Promise () at __awaiter (/home/backend/node_modules/@medusajs/medusa/dist/loaders/plugins.js:4:12) at /home/backend/node_modules/@medusajs/medusa/dist/loaders/plugins.js:296:87

A clear and concise description of what the bug is.

System information

Medusa version (including plugins): Node.js version:v16.13.0 Database: postgresql 14.3-1.pgdg20.04+1 Operating system: Ubuntu 20.04 Browser (if relevant): Chrome medusa-file-s3: 1.1.3

Steps to reproduce the behavior

  1. Follow this integration steps: https://docs.medusajs.com/add-plugins/s3
  2. Go to server directory
  3. run: npm start
  4. See error

Expected behavior

Start server and files upload to AWS S3

Wingrammer avatar Jul 10 '22 11:07 Wingrammer

This is likely because there is a mismatch between installations of medusa-interfaces.

In your Medusa project try reinstalling and restart:

$ yarn add medusa-interfaces
$ yarn start

srindom avatar Jul 10 '22 11:07 srindom

This is likely because there is a mismatch between installations of medusa-interfaces.

In your Medusa project try reinstalling and restart:

$ yarn add medusa-interfaces
$ yarn start

Thank you. When I tried that it gave me this error:

[email protected] build rm -rf dist && ./node_modules/.bin/tsc -p tsconfig.json

src/modules/invite/invite.service.ts:30:11 - error TS2345: Argument of type 'InviteServiceProps' is not assignable to parameter of type 'InviteServiceProps'. Types of property 'userService' are incompatible. Type 'import("/home/backend/src/modules/user/services/user.service").default' is not assignable to type 'import("/home/backend/node_modules/@medusajs/medusa/dist/services/user").default'.

30 super(container, configModule); ~~~~~~~~~

src/modules/order/order.subscriber.ts:73:17 - error TS2739: Type 'Product' is missing the following properties from type 'Product': store_id, store

73 const product: Product = await this.productService.retrieve(item.variant.product_id, { select: ['store_id']}); ~~~~~~~

src/modules/order/order.subscriber.ts:73:107 - error TS2322: Type '"store_id"' is not assignable to type 'keyof Product'.

73 const product: Product = await this.productService.retrieve(item.variant.product_id, { select: ['store_id']}); ~~~~~~~~~~

src/modules/product/services/product.service.ts:46:5 - error TS2416: Property 'prepareListQuery_' in type 'ProductService' is not assignable to the same property in base type 'ProductService'. Type '(selector: object, config: object) => object' is not assignable to type '(selector: FilterableProductProps | Selector<Product>, config: FindProductConfig) => { q: string; relations: (keyof Product)[]; query: FindWithoutRelationsOptions; }'. Type '{}' is missing the following properties from type '{ q: string; relations: (keyof Product)[]; query: FindWithoutRelationsOptions; }': q, relations, query

46 prepareListQuery_(selector: object, config: object): object { ~~~~~~~~~~~~~~~~~

src/modules/store/services/store.service.ts:31:2 - error TS2416: Property 'withTransaction' in type 'StoreService' is not assignable to the same property in base type 'StoreService'. Type '(transactionManager: EntityManager) => StoreService' is not assignable to type '(transactionManager?: EntityManager) => StoreService | this'. Type 'StoreService' is not assignable to type 'StoreService | this'. Type 'import("/home/backend/src/modules/store/services/store.service").default' is not assignable to type 'import("/home/backend/node_modules/@medusajs/medusa/dist/services/store").default'. Types of property 'retrieve' are incompatible. Type '(relations?: string[]) => Promise<Store>' is not assignable to type '(config?: FindConfig<Store>) => Promise<Store>'. Types of parameters 'relations' and 'config' are incompatible. Type 'FindConfig<Store>' is missing the following properties from type 'string[]': length, pop, push, concat, and 29 more.

31 withTransaction(transactionManager: EntityManager): StoreService { ~~~~~~~~~~~~~~~

src/modules/store/services/store.service.ts:98:15 - error TS2416: Property 'retrieve' in type 'StoreService' is not assignable to the same property in base type 'StoreService'. Type '(relations?: string[]) => Promise<Store>' is not assignable to type '(config?: FindConfig<Store>) => Promise<Store>'. Types of parameters 'relations' and 'config' are incompatible. Type 'FindConfig<Store>' is not assignable to type 'string[]'.

98 public async retrieve(relations: string[] = []) { ~~~~~~~~

src/modules/store/services/store.service.ts:100:26 - error TS2559: Type 'string[]' has no properties in common with type 'FindConfig<Store>'.

100 return super.retrieve(relations); ~~~~~~~~~

src/modules/store/services/store.service.ts:107:4 - error TS2769: No overload matches this call. Overload 1 of 2, '(options: FindOneOptions<Store>): Promise<Store>', gave the following error. Type '(qb: any) => void' is not assignable to type 'FindOptionsWhere<Store> | FindOptionsWhere<Store>[]'. Overload 2 of 2, '(options: FindOneOptions<Store>): Promise<Store>', gave the following error. Type '(qb: any) => void' is not assignable to type 'FindOptionsWhere<Store> | FindOptionsWhere<Store>[]'.

107 where: (qb) => { ~~~~~

node_modules/typeorm/find-options/FindOneOptions.d.ts:23:5 23 where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>; ~~~~~ The expected type comes from property 'where' which is declared here on type 'FindOneOptions<Store>' node_modules/typeorm/find-options/FindOneOptions.d.ts:23:5 23 where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>; ~~~~~ The expected type comes from property 'where' which is declared here on type 'FindOneOptions<Store>'

src/modules/user/services/user.service.ts:32:5 - error TS2416: Property 'withTransaction' in type 'UserService' is not assignable to the same property in base type 'UserService'. Type '(transactionManager: EntityManager) => UserService' is not assignable to type '(transactionManager?: EntityManager) => UserService | this'. Type 'UserService' is not assignable to type 'UserService | this'. Type 'import("/home/backend/src/modules/user/services/user.service").default' is not assignable to type 'import("/home/backend/node_modules/@medusajs/medusa/dist/services/user").default'. Property 'container' is private in type 'UserService' but not in type 'UserService'.

32 withTransaction(transactionManager: EntityManager): UserService { ~~~~~~~~~~~~~~~

src/modules/user/services/user.service.ts:42:16 - error TS2551: Property 'transactionManager' does not exist on type 'UserService'. Did you mean 'transactionManager_'?

42 cloned.transactionManager = transactionManager ~~~~~~~~~~~~~~~~~~

node_modules/@medusajs/medusa/dist/services/user.d.ts:22:15 22 protected transactionManager_: EntityManager; ~~~~~~~~~~~~~~~~~~~ 'transactionManager_' is declared here.

src/modules/user/services/user.service.ts:49:34 - error TS2339: Property 'validateId_' does not exist on type 'UserService'.

49 const validatedId = this.validateId_(userId); ~~~~~~~~~~~

src/modules/user/services/user.service.ts:66:22 - error TS2339: Property 'buildQuery_' does not exist on type 'UserService'.

66 return super.buildQuery_(selector, config); ~~~~~~~~~~~

Found 12 errors in 5 files.

Errors Files 1 src/modules/invite/invite.service.ts:30 2 src/modules/order/order.subscriber.ts:73 1 src/modules/product/services/product.service.ts:46 4 src/modules/store/services/store.service.ts:31 4 src/modules/user/services/user.service.ts:32

Wingrammer avatar Jul 10 '22 13:07 Wingrammer

Hi @Wingrammer - did you find a workaround ? I face the same issue after having installed the medusa-extender and tried the first step of the medusa marketplace blog post.

nicolama-dev avatar Aug 02 '22 16:08 nicolama-dev

Im having that same problem, any luck?

AidenH-dev avatar Aug 12 '22 18:08 AidenH-dev

Clone the Medusa marketplace as @nicolama-dev suggested. That implementation uses MINIO though. If you insist on using AWS S3 bucket, you would have to use a custom route with multer-s3 to do it yourself

Wingrammer avatar Aug 16 '22 14:08 Wingrammer