#The custom payment provider resolution is broken in the latest RC-5 release.

67 messages Β· Page 1 of 1 (latest)

ocean helm
#
error:   Error starting server
{
  name: 'ModuleProviderError',
  message: 'Errors while loading module providers for module payment:\n' +
    "Cannot find module './modules/payment-wayforpay'\n" +
    'Require stack:\n' +
    '- /.../node_modules/@medusajs/utils/dist/common/dynamic-import.js\n' +
    '- /.../node_modules/@medusajs/utils/dist/common/get-config-file.js\n' +
    '- /.../node_modules/@medusajs/utils/dist/common/index.js\n' +

stable sundial
#

Can you do ./src/modules/payment-wayforpay please?

#

And if it persists could you open an issue and reference it here please

hardy valley
#

I'm getting same error.

stable sundial
#

You are on the last rc? Can you share your version please

hardy valley
#

yes I've just updated from rc4 to 5

#

it works for 4

stable sundial
#

But can you share the version cause we released multiple today πŸ˜…

#

Is it this one that got installed 2.0.0-rc-20241015170251?

hardy valley
#

yes, 2.0.0-rc-20241015170251

stable sundial
#

I can see the issue is coming from the get config file util, is your medusa config file in ts?

hardy valley
#

yes it is .ts file

stable sundial
#

Can i get you to transform it to js in order to test a theory please, it would mean changing import to require and adding allowJs in your tsconfig file

hardy valley
stable sundial
#

As mentioned you need to move import to require

hardy valley
#

I changed import to
const { Modules, loadEnv, defineConfig } = require('@medusajs/framework/utils')

stable sundial
#

And if you can re add allowJs in your ts config, then you can retry and let me know

hardy valley
#

got this

stable sundial
#

Ok so this fix the config loading but then there is the loader issue, thank you very much for those elements. Could i get you to create an issue on GitHub referencing this conversation and then yoi can ref the issue here as well please πŸ™

#

And if you can share what command you are running and from where as well please

hardy valley
#

ok, got it thank you.

stable sundial
#

Can you just share the command and location from where you run it as well please

hardy valley
#

I'm not sure what you mean

stable sundial
#

To run your project, which command are you running and where are you running it from

hardy valley
#

ok, i run yarn dev from medusa-backend

stable sundial
#

Ok thank you very much, that way we have all the elements here as well

#

It gives us the steps to reproduce 😊always good to have

hardy valley
#

thanks

onyx scroll
#

Hello Wick!

I just created a new project with a custom module and all seems to be working fine.

Can you please push your code to some repo and share that with us?

hardy valley
short hemlock
#

same thing happens with custom notification provider

stable sundial
#

Morning guys
We found many issues with both your setup and some internal implementation. We will fix our issues and let you know about the changes you have to make on your project as well asap

stable sundial
#

Ok, so we have done the fixes that were needed on our side and are part of the rc-6, on your side here are the changes that you need to apply based on the previous RC changes:
You can move back your medusa-config.js to medusa-config.ts and therefore move back from require to import etc.
you need to change the resolve of the modules from @medusajs/the-module to @medusajs/medusa/the-module for all medusa modules that you are configuring.
in your package.json you need to change your dependencies/devDependencies to the following

"dependencies": {
    "@medusajs/admin-sdk": "rc",
    "@medusajs/framework": "rc",
    "@medusajs/medusa": "rc",
    "@medusajs/medusa-cli": "rc",
    "@mikro-orm/core": "5.9.7",
    "@mikro-orm/knex": "5.9.7",
    "@mikro-orm/migrations": "5.9.7",
    "@mikro-orm/postgresql": "5.9.7",
    "awilix": "^8.0.1",
    "pg": "^8.13.0"
  },
  "devDependencies": {
    "@mikro-orm/cli": "5.9.7",
    "@swc/jest": "^0.2.36",
    "medusa-test-utils": "rc",
    "@types/jest": "^29.5.13",
    "jest": "^29.7.0",
    "@types/node": "^20.0.0",
    "@swc/core": "1.5.7",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "vite": "^5.2.11"
  },

As you can see, no need to install the modules packages individually as they are part of the medusa package and reexported through sub path.

Can I get you to test it and report back here please πŸ™

hardy valley
#

I changed it all & update new rc, but getting this

#

......
but if I comment my custom payment module it works

stable sundial
#

can you change ./modules to ./src/modules and try again please

hardy valley
#

do i need to add ./src to all my custom modules ?

#

or only custom payment ?

stable sundial
#

to all relative path for your custom modules and providers

#

the doc need to be updated but we already mentioned it internally

#

since now we also have a standalone build everything will work even for the prod build since it mimics the directory structure

hardy valley
#

ok, thank you

hardy valley
#

get this error when run npx medusa db:migrate

onyx scroll
#

Ahuh! Thanks for finding all these hidden issues πŸ™‚

#

We are working on the fix

stable sundial
short hemlock
#

okay, changing path for module to ./src/modules works for notification providers, and also doesn't work for db:migrate command, same as Wick described with payment provider

ocean helm
#

Confirmed. Running npx medusa db:migrate still doesn’t resolve the providers.

runic pendant
#

I am running the rc version and had this error. I got the error fixed and the app is up and running. just that my new payment provider doesn't show up in the ui.
#1296242362925846548 message

stable sundial
runic pendant
# stable sundial This is because you have created a module and not a provider, you can already se...

gotcha!
i changes to provider. now i get this error

error:   Error starting server
Error: Cannot find module './modules/providers/razorpay'

tried changing from ./modules/ to ./src/modules and now my error message changers to this:

error:   Could not resolve module: Payment. Error: Loaders for module Payment failed: Trying to register a payment provider without a provider identifier.

error:   Error starting server
Error: Loaders for module Payment failed: Trying to register a payment provider without a provider identifier.

i followed the repo put by @onyx scroll https://github.com/thetutlage/medusa-payment-provider

edit: i updated to the latest rc but still getting the same error

rm -rf node_modules
rm yarn.lock

yarn
GitHub

Contribute to thetutlage/medusa-payment-provider development by creating an account on GitHub.

stable sundial
#

I ve summarized at different point the changes needed in the above discussion, can you change ./modules do ./src/modules and it seems that you are missing an identifier as per the error

#

I suggest you to follow the documentation πŸ‘Œ

runic pendant
# stable sundial I suggest you to follow the documentation πŸ‘Œ

i actually followed this documentation believing that it is the latest but then came here to realise that it is done differently. is there any other documentation you are referring to?

I have also cloned the above shared @onyx scroll 's repo into my local and tested and getting the same error.

Error: Loaders for module Payment failed: Trying to register a payment provider without a provider identifier.

one more thing i have observed is that after adding the provider and running the migration, it fails in couple of scenarios and passes in one scenario

so when i run npx medusa db:generate payment with resolve values ./src/modules/providers/crypto and ./modules/providers/crypto the migration failes with errors

info:    Generating migrations...
------------------------------------------
error:   Cannot find module './modules/providers/crypto'
info:    Generating migrations...
------------------------------------------
error:   Unable to resolve the migration scripts for the module payment
Cannot find module './src/modules/providers/crypto'

and when i run with the resolve value set to /src/modules/providers/crypto it passes

info:    Generating migrations...
------------------------------------------

info:    MODULE: payment
info:    Generated successfully (Migration20241017073405.ts).
------------------------------------------

info:    MODULE: payment
info:    Generated successfully (Migration20241017073406.ts).
------------------------------------------

info:    MODULE: payment
info:    Skipped. No changes detected in your models.
------------------------------------------
info:    Migrations generated

but i still cant apply the migration:

Explore Medusa's recipes, API references, configurations, storefront guides, and more.

onyx scroll
#

@runic pendant Can you please share your code as a repo?

hardy valley
#

Can I update new rc right now?

onyx scroll
hardy valley
runic pendant
unreal field
#

I was released just now