I am getting this error when using the package.
Yep, we're aware of this issue! Happens when conditionally enabling the plugin. Check out
https://github.com/payloadcms/plugin-cloud-storage/issues/54where it's being tracked.
Original discussion is here:
https://discord.com/channels/967097582721572934/1102878160544079983/1116782409002799175
Best thing you can do for now is manually include the alias in your webpack config or make sure that the cloud storage plugin is always enabled
can you guide me how to make the cloud-storage-plugin to be always enable ?
Pretty much just make sure the cloud plugin is always added to your plugins array in your payload config!
Could you share the payload config you currently use where you're getting that error?
export default buildConfig({
serverURL: 'http://localhost:3000',
admin: {
user: Users.slug,
buildPath: path.resolve(process.cwd(), 'build/'),
},
collections: [
Users,
Logs,
VehicleInfos,
Projects
],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
plugins: [
// Pass the plugin to Payload
cloudStorage({
collections: {
// Enable cloud storage for Media collection
media: {
// Create the S3 adapter
adapter: s3Adapter({
config: {
endpoint: process.env.S3_ENDPOINT,
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
},
},
bucket: process.env.S3_BUCKET,
}),
},
},
}),
],
});
hmm strange. @denolfe check this out, seems it still happens despite it not being enabled conditionally
Is this happening with this very same config after you've deleted node_modules and installed it again?
Wondering if webpack cached the previous webpack config 🤔
Yep still getting the error , also tried using npm instead of yarn just in case that might work. But that also didnt.
The issue is due to conditionally enabling the plugin. If you include the plugin code at all, regardless of whether you put it into your plugins array, the webpack aliasing still needs to run.
TLDR above ☝️ I'm working on a proper way to conditionally enable this plugin against this issue:
https://github.com/payloadcms/plugin-cloud-storage/issues/54PR soon
The thing here is, judging from the code he shared, he wasn't conditionally enabling the plugin and still got the error
Interesting, yeah I didn't read your comment well 😅
im having the same problem, im also not condtionally including the plugin
this may have something to do with webpack and its trying to include fs on the client-side, its what i suspect, but im not sure
@olarssony @zinox9 I made a few small adjustments on the webpack config in 1.0.17. Can you give that a try and see if the behavior is any different?
Will check it out tomorrow at work!
Deleted node_modules and upgraded and checked , still the same issue here 🧐
I loaded up your config (with different collections), and I'm able to build without any webpack issue. Not sure what could be going on here 🤔
Oh, I think I may know what it is
You have your plugin looking for a collection slug of
media
. Does this collection slug exist? Your collections don't look like they have something that would have a slug of media.
collections: [Users, Logs, VehicleInfos, Projects],
Do any of these have a collection slug of
media
? This should correspond with a collection with uploads enabled.
oh I see, I didnt notice we can specify the collection specifically here. I will try it out again and see if it works.
Yep, Its working fine now. Thanks for the help !
The Setup looked like it was a default structure and I didn't notice that we were specifying the collections from our end. My bad 😅
All good, we should probably validate if the slug is valid. There wasn't a very helpful error.
Id be surprised if this was the problem for me, but ill check once i have thr code in front of me again
this seems to have done it for me, uploading media to the cloud now works again. thx!
Amazing 🙌
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.