payload-auth-plugin: The plugin does not work when run and produces an error: [PAYLOAD_AUTH_PLUGIN_ERROR: Missing users collection]
Describe the bug
I am following the tutorial from https://authsmith.com/docs/plugins/payload/installation, but until now I can’t use it because when running npm run dev, payloadcms always produces an error:
If I look at the example of usage in this Youtube tutorial https://www.youtube.com/watch?v=ahlk76lsqD0&t=22s, it should automatically create the Accounts collection, right? I’m new to Payloadcms, if there are any steps I missed, please correct me, thank you.
My package.json:
My payload.config.ts:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 26
Ah I see, this works although I have to make some adjustments to the existing code. Thanks @itzpere !
Should I close this issue or is there something you want resolved @sourabpramanik ?
You should set type to module because If this field is not present, Node.js will treat the files as CommonJS modules by default.
I tried this after doing that, but it’s still the same.
Ah, it turns out it was our engineer’s fault, so I just need to add the
userscollection manually. (It seems it was previously deleted).One more question, if I want to add an
accountscollection to make writing code easier and ensure type safety (safety props typing) in TypeScript, do I need to add it manually intopayload.config.ts?You can read about it here
Payload by default will create a Users collection with slug “users” as it will use it to store the admin users. This plugin will use the same collection slug as well to process the auth.
In your project look for “/src/collections/Users/index.ts”. Let me know if you are able to find it