Getting the following error after installing and configuring
@payloadcms/plugin-cloud-storge
.
ERROR in ./node_modules/@payloadcms/plugin-cloud-storage/dist/adapters/s3/handleUpload.js 43:27-40
Module not found: Error: Can't resolve 'fs' in '/usr/src/app/node_modules/@payloadcms/plugin-cloud-storage/dist/adapters/s3'
I saw in another community post that maybe I need to setup an alias to
fs
in the webpack config. The README for this plugin doesn't state that however. I'm going to give it a go but if that's unintended, I'd like to know.
Thanks!
Adding the alias seems to have worked, though I think (if possible) it'd be better if the package could avoid requiring
fs
if it's being compiled client side.
Here's what I did in case someone searches in here to find an answer and missed it on the website:
mocks/emptyObject.js
export default {}
payload.config.ts
import path from 'path'
const mockModulePath = path.resolve(__dirname, 'mocks/emptyObject.js')
export default buildConfig({
serverURL: 'http://localhost:3000',
admin: {
webpack: (config) => {
return {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
'fs': mockModulePath,
}
}
};
},
...
Then it compiled just fine. I also had to add a
region
property to the s3 config. That wasn't immediately called out in the readme.
Hope this is helpful to someone!