payload: plugin-cloud-storage: Can't resolve 'fs' error with cloud-storage-plugin s3 adapter
Link to reproduction
https://github.com/haliacmon/payload-reproduction
Describe the Bug
Getting Module not found: Error: Can’t resolve ‘fs’ error with plugin-cloud-storage and s3-adapter
ERROR in ./node_modules/.pnpm/@payloadcms+plugin-cloud-storage@1.1.1_@aws-sdk+client-s3@3.454.0_@aws-sdk+lib-storage@3.454.0_payload@2.1.1/node_modules/@payloadcms/plugin-cloud-storage/dist/adapters/s3/handleUpload.js 140:27-40
Module not found: Error: Can't resolve 'fs' in '...\node_modules\.pnpm\@payloadcms+plugin-cloud-storage@1.1.1_@aws-sdk+client-s3@3.454.0_@aws-sdk+lib-storage@3.454.0_payload@2.1.1\node_modules\@payloadcms\plugin-cloud-storage\dist\adapters\s3'
To Reproduce
1- npx create-payload-app@latest reproduce-error-s3 -t blank --use-pnpm using postgress 2- pnpm add @payloadcms/plugin-cloud-storage 3- pnpm add @aws-sdk/client-s3 @aws-sdk/lib-storage aws-crt 4- optional. add s3 related variables to .env. Not necessary to reproduce the error. 5- adding build config for plugin-cloud-storage & s3-adapter by instructions. (error happens after step 5) https://github.com/payloadcms/payload/tree/c10db332cdeb3f702d378b0649be20eb789c13e1/packages/plugin-cloud-storage#s3-adapter
//payload.config.ts
...
import { cloudStorage } from '@payloadcms/plugin-cloud-storage'
import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3'
const adapter = s3Adapter({
config: {
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
},
region: process.env.S3_REGION,
},
bucket: process.env.S3_BUCKET,
})
...
plugins: [
...
cloudStorage({
collections: {
"my-collection-slug": {
adapter: adapter,
},
},
}),
],
...
Payload Version
2.1.1
Adapters and Plugins
db-postgres, plugin-cloud-storage, S3 Adapter
About this issue
- Original URL
- State: open
- Created 7 months ago
- Reactions: 6
- Comments: 22 (7 by maintainers)
Can confirm I’m also running into this issue.
Your mileage may vary by disabling those features. I’ve been trying similar stuff. something else to note if you want to preserve + override the webpack config you can do it like this:
I found a a workaround.
If I add this to buildConfig() error goes away
@haliacmon Just published a new beta to try.
@ericuldall We’ve identified some issues w/ the vite bundler with this package that are yet to be resolved 👍
more errors this time.